Results 1 to 11 of 11
  1. #1
    JBeese is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default More problems writing this code. any help appreciated.

    Java Code:
    /*
    	documentation section
    	program:RetailSales
    	name: 	Beese
    	date: 	June.2011
    */
    
    import java.awt.*;
    import javax.swing.*;
    import java.text.*;
    import java.awt.event.*;
    
    
    public class RetailSales extends JFrame
    {
    	/* --------------------------------- declarations */
    
    	// color objects
    	Color black = new Color(0, 0, 0);
    	Color white = new Color(255, 255, 255);
    
       // number formats
       DecimalFormat currency; // declaration statement 
       
    	
    	// components
    	JLabel numberOfItemsJLabel;
    	JTextField numberOfItemsJTextField;
    	
    	JLabel priceOfItemsJLabel;
    	JTextField priceOfItemsJTextField;
    	
    	JLabel subTotalJLabel;
    	JTextField subTotalJTextField;
    	
    	JLabel salesTaxJLabel;
    	JTextField salesTaxJTextField;
    	
    	JLabel totalAmountJLabel;
    	JTextField totalAmountJTextField;
    	
    	JButton enterJButton;
    	
    	JButton clearJButton;
    
    
    
    	// variables - constants
    	
    	int numberOfItems;
    	double priceOfItems;
    	double subTotal;
    	double totalAmount;
    	double salesTax;
    	final double TAX_RATE;
    		
    
    
    
       	public RetailSales()
       	{
          		createUserInterface();
       	}
    
       	public void createUserInterface()
       	{
    		Container contentPane = getContentPane();
    		contentPane.setBackground(white);
    		contentPane.setLayout(null);
    
    		//initialize components
    		currency = new DecimalFormat("$0.00");
    		
    		TAX_RATE = .06;
    		 
    			
    		numberOfItemsJLabel = new JLabel();
    		numberOfItemsJLabel.setBounds(75, 50, 100, 20);
    		numberOfItemsJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		numberOfItemsJLabel.setText("Number Of Items:");
    		numberOfItemsJLabel.setForeground(black);
    		numberOfItemsJLabel.setHorizontalAlignment(JLabel.CENTER);
    		contentPane.add(numberOfItemsJLabel);
    		
    		numberOfItemsJTextField = new JTextField();
    		numberOfItemsJTextField.setBounds(225, 50, 50, 20);
    		numberOfItemsJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		numberOfItemsJTextField.setHorizontalAlignment(JTextField.CENTER);
    		numberOfItemsJTextField.setForeground(black);
    		numberOfItemsJTextField.setBackground(white);
    		numberOfItemsJTextField.setEditable(true);
    		contentPane.add(numberOfItemsJTextField);
    		
    		priceOfItemsJLabel = new JLabel();
    		priceOfItemsJLabel.setBounds(75, 80, 100, 20);
    		priceOfItemsJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		priceOfItemsJLabel.setText("Price Per Item:");
    		priceOfItemsJLabel.setForeground(black);
    		priceOfItemsJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(priceOfItemsJLabel);
    
    		priceOfItemsJTextField = new JTextField();
    		priceOfItemsJTextField.setBounds(225, 80, 50, 20);
    		priceOfItemsJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		priceOfItemsJTextField.setHorizontalAlignment(JTextField.CENTER);
    		priceOfItemsJTextField.setForeground(black);
    		priceOfItemsJTextField.setBackground(white);
    		priceOfItemsJTextField.setEditable(true);
    		contentPane.add(priceOfItemsJTextField);
    		
    		subTotalJLabel = new JLabel();
    		subTotalJLabel.setBounds(75, 130, 100, 20);
    		subTotalJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		subTotalJLabel.setText("Sub Total:");
    		subTotalJLabel.setForeground(black);
    		subTotalJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(subTotalJLabel);
    
    		subTotalJTextField = new JTextField();
    		subTotalJTextField.setBounds(225, 130, 50, 20);
    		subTotalJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		subTotalJTextField.setHorizontalAlignment(JTextField.CENTER);
    		subTotalJTextField.setForeground(black);
    		subTotalJTextField.setBackground(white);
    		subTotalJTextField.setEditable(false);
    		contentPane.add(subTotalJTextField);
    
          salesTaxJLabel = new JLabel();
    		salesTaxJLabel.setBounds(75, 160, 100, 20);
    		salesTaxJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		salesTaxJLabel.setText("Sales Tax:");
    		salesTaxJLabel.setForeground(black);
    		salesTaxJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(salesTaxJLabel);
    
    		salesTaxJTextField = new JTextField();
    		salesTaxJTextField.setBounds(225, 160, 50, 20);
    		salesTaxJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		salesTaxJTextField.setHorizontalAlignment(JTextField.CENTER);
    		salesTaxJTextField.setForeground(black);
    		salesTaxJTextField.setBackground(white);
    		salesTaxJTextField.setEditable(false);
    		contentPane.add(salesTaxJTextField);
    		
    		totalAmountJLabel = new JLabel();
    		totalAmountJLabel.setBounds(75, 190, 100, 20);
    		totalAmountJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		totalAmountJLabel.setText("Total Amount:");
    		totalAmountJLabel.setForeground(black);
    		totalAmountJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(totalAmountJLabel);
    
    		totalAmountJTextField = new JTextField();
    		totalAmountJTextField.setBounds(225, 190, 50, 20);
    		totalAmountJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		totalAmountJTextField.setHorizontalAlignment(JTextField.CENTER);
    		totalAmountJTextField.setForeground(black);
    		totalAmountJTextField.setBackground(white);
    		totalAmountJTextField.setEditable(false);
    		contentPane.add(totalAmountJTextField);
    		
    		enterJButton = new JButton();
    		enterJButton.setBounds(70, 300, 75, 20);
    		enterJButton.setFont(new Font("Default", Font.PLAIN, 12));
    		enterJButton.setText("Enter");
    		enterJButton.setForeground(black);
    		enterJButton.setBackground(white);
    		contentPane.add(enterJButton);
    		enterJButton.addActionListener(
    		
    		        new ActionListener()
    				  {
    				          public void actionPerformed(ActionEvent event)
    							 {
    							         enterJButtonActionPerformed(event);
    							 }
    				  }
    	    );	
    		 
    		 clearJButton = new JButton();
    		 clearJButton.setBounds(200, 300, 75, 20);
    		 clearJButton.setFont(new Font("Default", Font.PLAIN, 12));
    		 clearJButton.setText("Clear");
    		 clearJButton.setForeground(black);
    		 clearJButton.setBackground(white);
    		 contentPane.add(clearJButton);
    		 clearJButton.addActionListener(
    
    			     new ActionListener()
    			     {
    				         public void actionPerformed(ActionEvent event)
    				         {
    					             clearJButtonActionPerformed(event);
    				         }
    			      }
    		  );
    		  			 			
    		
    		// set properties of application’s window
    		setTitle("RetailSales");
    		setSize(400, 400);
    		setVisible(true);
       	}
    		
       	// main method
       	public static void main(String[] args)
       	{
          		RetailSales application = new RetailSales();
          		application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
       	}
    		
    			public void enterJButtonActionPerformed(ActionEvent event)
    	{
    			getNumberOfItems();
    	}
    
    	public void getNumberOfItems()
    	{
    		try
    		{
    			numberOfItems = Integer.parseInt(numberOfItemsJTextField.getText());
    			getPriceOfItems();
    		}
    		catch(NumberFormatException exception)
    		{
    		      	JOptionPane.showMessageDialog(this,
    		       	"Please enter Number of Items!",
    		        "Number Format Error", JOptionPane.ERROR_MESSAGE );
    		        numberOfItemsJTextField.setText("");
    		        numberOfItemsJTextField.requestFocusInWindow();
    		}
    	}
    
    	public void getPriceOfItems()
    	{
    		try
    		{
    			priceOfItems = Double.parseDouble(priceOfItemsJTextField.getText());
    			getSubTotal();
    		}
    		catch(NumberFormatException exception)
    		{
    		      	JOptionPane.showMessageDialog(this,
    		       	"Please enter Price per Item!",
    		        "Number Format Error", JOptionPane.ERROR_MESSAGE );
    		        priceOfItemsJTextField.setText("");
    		        priceOfItemsJTextField.requestFocusInWindow();
    		}
    	}
    
    	public void getSubTotal()
    	{
    		subTotal = calculateSum(numberOfItems,priceOfItems);
    		displayOutput();
    	}
    
    	public double calculateSum(int valueOne, double valueTwo)
    	{
    		return valueOne * valueTwo;
    	}
    
    	public void displayOutput()
    	{
    		subTotalJTextField.setText("" + currency.format(subTotal));
    	}
    	
    	public void salesTax
        {
    	   salesTax = calculateSum(subTotal,SALES_TAX);
    		salesTax();
    	 } 	
    		
    	public double calculateSum(double valueThree, double valueFour)
    	{
    	   return valueThree * valueFour;
    	}
    	
    	public void salesTax()
    	{
    	    salesTaxJTextField.setText("" + currency.format(salesTax));
       }	
    	
    	
    
    	public void clearJButtonActionPerformed(ActionEvent event)
    	{
    		numberOfItemsJTextField.setText("");
    		numberOfItemsJTextField.requestFocusInWindow();
    		priceOfItemsJTextField.setText("");
    		subTotalJTextField.setText("");
    	}		
    		
    		
    		
    		
    		
    	}

    Now when i compile i get this error message

    RetailSales.java:269: '(' expected
    {
    ^
    1 error

    when i close it with ( i get 7 different error messages. Im starting to think i should just drop this class and go work at McDonalds or something.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You are breaking a cardinal rule of programming: don't add more code to bad code. The key (if you are not using an IDE) is to compile your code early and often as you create it, preferably after adding each line. If your code has a compilation error, then you must fix the error, and you don't add any more code until the error has been fixed.

    So you've got a bunch of errors in the code above, but one that may be causing your problem is that you appear to have two methods with the same name, salesTax, and one doesn't even have the () necessary for methods.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Edit: actually there are fewer errors than I thought, but again first and foremost- get rid of that bad salesTax method, the one without the () parenthesis. Just delete it.

  4. #4
    JBeese is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    This is all really confusing, I don't know how to write this stuff, thanks alot for the help, but every time i think i figure one problem out, i get like 10 more issues. this is lesson 3/10 if im having this many issues with the third assignment i cant imagine taking a final exam with the expectation of passing. Ill sleep on it and try to figure it out in the morning.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JBeese View Post
    This is all really confusing, I don't know how to write this stuff,
    Yes, it's real hard at first, but the more you do, the easier it gets. Just keep at it, don't give up, and try to write lots and lots of code. Believe me, it will pay off in the end.

    thanks alot for the help, but every time i think i figure one problem out, i get like 10 more issues. this is lesson 3/10 if im having this many issues with the third assignment i cant imagine taking a final exam with the expectation of passing. Ill sleep on it and try to figure it out in the morning.
    Again, the key is to not give up and to not panic. Remember that a journey of a thousand miles begins with a single step.

  6. #6
    JBeese is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Angry

    Java Code:
    /*
    	documentation section
    	program:RetailSales
    	name: 	Beese
    	date: 	June.2011
    */
    
    import java.awt.*;
    import javax.swing.*;
    import java.text.*;
    import java.awt.event.*;
    
    
    public class RetailSales extends JFrame
    {
    	/* --------------------------------- declarations */
    
    	// color objects
    	Color black = new Color(0, 0, 0);
    	Color white = new Color(255, 255, 255);
    
       // number formats
       DecimalFormat currency; // declaration statement 
    	
       
    	
    	// components
    	JLabel numberOfItemsJLabel;
    	JTextField numberOfItemsJTextField;
    	
    	JLabel priceOfItemsJLabel;
    	JTextField priceOfItemsJTextField;
    	
    	JLabel subTotalJLabel;
    	JTextField subTotalJTextField;
    	
    	JLabel salesTaxJLabel;
    	JTextField salesTaxJTextField;
    	
    	JLabel totalAmountJLabel;
    	JTextField totalAmountJTextField;
    	
    	JButton enterJButton;
    	
    	JButton clearJButton;
    
    
    
    	// variables - constants
    	
    	int numberOfItems;
    	double priceOfItems;
    	double subTotal;
    	double totalAmount;
    	double salesTax;
    	final double TAX_RATE = .06;
    
    			
    
    
    
       	public RetailSales()
       	{
          		createUserInterface();
       	}
    
       	public void createUserInterface()
       	{
    		Container contentPane = getContentPane();
    		contentPane.setBackground(white);
    		contentPane.setLayout(null);
    
    		//initialize components
    		currency = new DecimalFormat("$0.00");
    		
    
    		
    		
    		
    		
    		
    				 
    			
    		numberOfItemsJLabel = new JLabel();
    		numberOfItemsJLabel.setBounds(75, 50, 100, 20);
    		numberOfItemsJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		numberOfItemsJLabel.setText("Number Of Items:");
    		numberOfItemsJLabel.setForeground(black);
    		numberOfItemsJLabel.setHorizontalAlignment(JLabel.CENTER);
    		contentPane.add(numberOfItemsJLabel);
    		
    		numberOfItemsJTextField = new JTextField();
    		numberOfItemsJTextField.setBounds(225, 50, 50, 20);
    		numberOfItemsJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		numberOfItemsJTextField.setHorizontalAlignment(JTextField.CENTER);
    		numberOfItemsJTextField.setForeground(black);
    		numberOfItemsJTextField.setBackground(white);
    		numberOfItemsJTextField.setEditable(true);
    		contentPane.add(numberOfItemsJTextField);
    		
    		priceOfItemsJLabel = new JLabel();
    		priceOfItemsJLabel.setBounds(75, 80, 100, 20);
    		priceOfItemsJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		priceOfItemsJLabel.setText("Price Per Item:");
    		priceOfItemsJLabel.setForeground(black);
    		priceOfItemsJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(priceOfItemsJLabel);
    
    		priceOfItemsJTextField = new JTextField();
    		priceOfItemsJTextField.setBounds(225, 80, 50, 20);
    		priceOfItemsJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		priceOfItemsJTextField.setHorizontalAlignment(JTextField.CENTER);
    		priceOfItemsJTextField.setForeground(black);
    		priceOfItemsJTextField.setBackground(white);
    		priceOfItemsJTextField.setEditable(true);
    		contentPane.add(priceOfItemsJTextField);
    		
    		subTotalJLabel = new JLabel();
    		subTotalJLabel.setBounds(75, 130, 100, 20);
    		subTotalJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		subTotalJLabel.setText("Sub Total:");
    		subTotalJLabel.setForeground(black);
    		subTotalJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(subTotalJLabel);
    
    		subTotalJTextField = new JTextField();
    		subTotalJTextField.setBounds(225, 130, 50, 20);
    		subTotalJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		subTotalJTextField.setHorizontalAlignment(JTextField.CENTER);
    		subTotalJTextField.setForeground(black);
    		subTotalJTextField.setBackground(white);
    		subTotalJTextField.setEditable(false);
    		contentPane.add(subTotalJTextField);
    
          salesTaxJLabel = new JLabel();
    		salesTaxJLabel.setBounds(75, 160, 100, 20);
    		salesTaxJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		salesTaxJLabel.setText("Sales Tax:");
    		salesTaxJLabel.setForeground(black);
    		salesTaxJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(salesTaxJLabel);
    
    		salesTaxJTextField = new JTextField();
    		salesTaxJTextField.setBounds(225, 160, 50, 20);
    		salesTaxJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		salesTaxJTextField.setHorizontalAlignment(JTextField.CENTER);
    		salesTaxJTextField.setForeground(black);
    		salesTaxJTextField.setBackground(white);
    		salesTaxJTextField.setEditable(false);
    		contentPane.add(salesTaxJTextField);
    		
    		totalAmountJLabel = new JLabel();
    		totalAmountJLabel.setBounds(75, 190, 100, 20);
    		totalAmountJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    		totalAmountJLabel.setText("Total Amount:");
    		totalAmountJLabel.setForeground(black);
    		totalAmountJLabel.setHorizontalAlignment(JLabel.LEFT);
    		contentPane.add(totalAmountJLabel);
    
    		totalAmountJTextField = new JTextField();
    		totalAmountJTextField.setBounds(225, 190, 50, 20);
    		totalAmountJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    		totalAmountJTextField.setHorizontalAlignment(JTextField.CENTER);
    		totalAmountJTextField.setForeground(black);
    		totalAmountJTextField.setBackground(white);
    		totalAmountJTextField.setEditable(false);
    		contentPane.add(totalAmountJTextField);
    		
    		enterJButton = new JButton();
    		enterJButton.setBounds(70, 300, 75, 20);
    		enterJButton.setFont(new Font("Default", Font.PLAIN, 12));
    		enterJButton.setText("Enter");
    		enterJButton.setForeground(black);
    		enterJButton.setBackground(white);
    		contentPane.add(enterJButton);
    		enterJButton.addActionListener(
    		
    		        new ActionListener()
    				  {
    				          public void actionPerformed(ActionEvent event)
    							 {
    							         enterJButtonActionPerformed(event);
    							 }
    				  }
    	    );	
    		 
    		 clearJButton = new JButton();
    		 clearJButton.setBounds(200, 300, 75, 20);
    		 clearJButton.setFont(new Font("Default", Font.PLAIN, 12));
    		 clearJButton.setText("Clear");
    		 clearJButton.setForeground(black);
    		 clearJButton.setBackground(white);
    		 contentPane.add(clearJButton);
    		 clearJButton.addActionListener(
    
    			     new ActionListener()
    			     {
    				         public void actionPerformed(ActionEvent event)
    				         {
    					             clearJButtonActionPerformed(event);
    				         }
    			      }
    		  );
    		  			 			
    		
    		// set properties of application’s window
    		setTitle("RetailSales");
    		setSize(400, 400);
    		setVisible(true);
       	}
    		
       	// main method
       	public static void main(String[] args)
       	{
          		RetailSales application = new RetailSales();
          		application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
       	}
    		
    			public void enterJButtonActionPerformed(ActionEvent event)
    	{
    			getNumberOfItems();
    	}
    
    	public void getNumberOfItems()
    	{
    		try
    		{
    			numberOfItems = Integer.parseInt(numberOfItemsJTextField.getText());
    			getPriceOfItems();
    		}
    		catch(NumberFormatException exception)
    		{
    		      	JOptionPane.showMessageDialog(this,
    		       	"Please enter Number of Items!",
    		        "Number Format Error", JOptionPane.ERROR_MESSAGE );
    		        numberOfItemsJTextField.setText("");
    		        numberOfItemsJTextField.requestFocusInWindow();
    		}
    	}
    
    	public void getPriceOfItems()
    	{
    		try
    		{
    			priceOfItems = Double.parseDouble(priceOfItemsJTextField.getText());
    			getSubTotal();
    		}
    		catch(NumberFormatException exception)
    		{
    		      	JOptionPane.showMessageDialog(this,
    		       	"Please enter Price per Item!",
    		        "Number Format Error", JOptionPane.ERROR_MESSAGE );
    		        priceOfItemsJTextField.setText("");
    		        priceOfItemsJTextField.requestFocusInWindow();
    		}
    	}
    
    	public void getSubTotal()
    	{
    		subTotal = calculateSum(numberOfItems,priceOfItems);
    		getSalesTax();
    	}
    
    	public double calculateSum(int numberOfItems, double valueTwo)
    	{
    		return numberOfItems * priceOfItems;
    	}
    
    	public void getSalesTax()
    	{
    		subTotalJTextField.setText("" + currency.format(subTotal));
    	}
    	
    	public void taxRate()
    	{
    	   salesTax = calculateSum(subTotal,TAX_RATE);
    	   getTotal();
    	}
    	
    	public double calculateSum(double subTotal, final double TAX_RATE)
    	{
    	    return subTotal * TAX_RATE;
    	}
    	
    	public void getTotal()
    	{
    	    	 
    	    salesTaxJTextField.setText("" + currency.format(salesTax));
    	}	   
    	
    	
    	public void clearJButtonActionPerformed(ActionEvent event)
    	{
    		numberOfItemsJTextField.setText("");
    		numberOfItemsJTextField.requestFocusInWindow();
    		priceOfItemsJTextField.setText("");
    		subTotalJTextField.setText("");
    	}		
    		
    	}
    So i rewrote the code this morning after some sleep, it now compiles and runs but still doesnt calculate the sales tax, im thinking maybe i dont have the TAX_RATE set to .06 correctly, i tried putting TAX_RATE = .06 down lower under the initialize components section but that didnt work. /sigh
    Last edited by JBeese; 06-05-2011 at 04:47 PM.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You display the data to the salesTaxJTextField in the getTotal() method which is called by the GetTotal() method (confusing naming!), but this is called by nothing, so no sales tax is displayed.

    Suggestion: combine the getTotal and GetTotal code into one method called getTotal (method and variable names should begin with lower case letters), and then call this method somewhere in your code where you need to calculate and display the salesTax.

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    Remember that a journey of a thousand miles begins with a single step.
    How old fashioned; my thousand mile journeys always begin with me buying an airplane ticket ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    JBeese is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    Oops GetTotal was supposed to be GetTax(ive since renamed to taxRate) and i was typing fast, Im a little confused all i did for this section was basically copy/paste the code for calculating subtotal and just changed the names. The course materials say im to write the code in this method: I dont know why it worked for one section(the subtotal) and not this one, isnt the method call written on 278 with the method itself on 286? i need a better book heh.

    Java Code:
    public void Calculate OutPut()
    	{
    	   resultNumber = calculateSum(firstNumber,secondNUmber);
    	   displayOutPut();
    	}
    	
    	public double calculateSum(double firstNumber,  double secondNumber)
    	{
    	    return firstNumber * secondNumber;
    	}
    	
    	public void displayOutput()
    	{
    	    	 
    	    resultnumberJTextField.setText("" + currency.format(resultNumber));
    	}

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default

    Quote Originally Posted by JosAH View Post
    How old fashioned; my thousand mile journeys always begin with me buying an airplane ticket ;-)

    kind regards,

    Jos
    That's because you're well employed. Mine begin (and sometimes end) with checking my bank balance

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by DarrylBurke View Post
    That's because you're well employed. Mine begin (and sometimes end) with checking my bank balance
    My boss is a creep; all he wants me to do is work, work, work; I feel like an ant with a number stamped on my back. I'm self employed.

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Problems with writing String values to a text file
    By Tedward in forum New To Java
    Replies: 8
    Last Post: 06-02-2011, 04:28 AM
  2. Problem with KeyPressed any Help is appreciated
    By gryd00 in forum New To Java
    Replies: 3
    Last Post: 05-17-2011, 05:15 PM
  3. help writing a java code
    By joshsmith3400 in forum Forum Lobby
    Replies: 1
    Last Post: 02-02-2011, 07:06 AM
  4. Writing code seamlessly...
    By JoshNerd557 in forum New To Java
    Replies: 2
    Last Post: 12-07-2010, 01:51 AM
  5. Problems writing to an outputstream
    By higashij in forum Java Servlet
    Replies: 1
    Last Post: 09-12-2009, 07:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •