Java please help what variables whould i change to make this into a seperate class?
-
please help i need to make a seperate class to do these calculations an invoice class and im not sure what to do bc i just wrote the code on the GUI class when the calculate button is clicked but i need to make a seperate class that has the calculations then call it througgh the main class. private void calculateJButtonActionPerformed( ActionEvent event ) { // get user inputs String orderNumber = orderNumberJTextField.getText(); String name = nameJTextField.getText(); String address1 = addressJTextField1.getText(); String address2 = addressJTextField2.getText(); // total of white/black dice ordered double whiteTotals = 0.0; // total of red/black dice ordered double redTotals = 0.0; // calculate price if white/black JCheckBox is selected if ( whiteTypeJCheckBox.isSelected() ) { whiteTotals = Integer.parseInt( whiteQuantityJTextField.getText() ) * 6.25; } // calculate price if red/black JCheckBox is selected if ( redTypeJCheckBox.isSelected() ) { redTotals = Integer.parseInt( redQuantityJTextField.getText() ) * 5.00; } // display message if order number, name or address is empty if ( orderNumber.equals( "" ) || name.equals( "" ) || address1.equals( "" ) || address2.equals( "" ) || orderNumber.equals( "0" ) || name.equals( "Enter name here" ) || address1.equals( "Address Line 1" ) || address2.equals( "City, State, Zip" ) ) { // display message JOptionPane.showMessageDialog( null, "Please fill out all information fields.", "Empty Fields", JOptionPane.WARNING_MESSAGE ); } else if ( !whiteTypeJCheckBox.isSelected() && !redTypeJCheckBox.isSelected() ) { // display message if no JCheckBox is // selected and its quantity is 0 JOptionPane.showMessageDialog( null, "Please select an item and enter a quantity.", "No Item selected", JOptionPane.WARNING_MESSAGE ); } else // otherwise, calculate totals { // set display format DecimalFormat dollars = new DecimalFormat( "$0.00" ); // display totals of dice ordered whiteTotalsJTextField.setText( dollars.format( whiteTotals ) ); redTotalsJTextField.setText( dollars.format( redTotals ) ); // calculate and display subtotal double subtotal = whiteTotals + redTotals; subtotalJTextField.setText( dollars.format( subtotal ) ); // calculate and display tax double tax = subtotal * 0.05; taxJTextField.setText( dollars.format( tax ) ); // calculate and display total totalJTextField.setText( dollars.format( subtotal + tax ) ); } // end else }
-
Answer:
LOL
B at Yahoo! Answers Visit the source
Related Q & A:
- How do I change HTML content to be a JS variable?Best solution by ehow.com
- The pores on my face are wideninf by the minute. Please help me so that I can have them the normal size?Best solution by Yahoo! Answers
- How do I get a job in IT or Software Development if I have no experience and only a 3rd class degree?Best solution by answers.yahoo.com
- Altering my business card, What should I change to make it better? (In exchange for 10 points B/A Thank you?
- Please help me how can i change my mobile number in yahoo messanger?Best solution by answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.