Results 1 to 18 of 18
  1. #1
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Exclamation [SOLVED] Please help with output!!!

    Please help me out with my code. This is my code. In my output only the Quantity ordered is displaying. Everything else is all 0's.

    Thank you in advance.


    Java Code:
    import java.text.DecimalFormat;
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.event.*;
    
    
    public class Main extends JFrame implements ActionListener
    {
    	
    	 // All the GUI objects
        JPanel mainPanel = new JPanel();
        JLabel storeLabel = new JLabel("       OrderBook INC.         ");
        JTextField bookNameTextField = new JTextField(20);
        JTextField quantityTextField = new JTextField(20);
        JTextField priceTextField = new JTextField(20);
        JButton calculateButton = new JButton(" Calculate   ");
        JTextArea outputTextArea = new JTextArea("Books Ordered", 10, 25);
        JScrollPane outputScrollPane = new JScrollPane(outputTextArea);
    	
    	int quantityInteger;
    	double priceDouble;
    	String nameString;
    	
        //object of the font
        Font storeFont = new Font("Arial",Font.BOLD,14);
    
    	public static void main(String[] args)
    	{
    		Main myBooks = new Main();
    		myBooks.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    	}
    	
    	public Main()
    	{
    		designFrame();
    		
    	}
    	
    	
    	public void designFrame()
    	{
            //set the font and the color
            storeLabel.setFont(storeFont);
            storeLabel.setForeground(Color.GRAY);
        
            //add the components to the mainPanel
            mainPanel.add(storeLabel);
            mainPanel.add(new JLabel("       Book Name            "));
            mainPanel.add(bookNameTextField);
            mainPanel.add(new JLabel("    Quantity Ordered   "));
            mainPanel.add(quantityTextField);
            mainPanel.add(new JLabel("    Price       "));
            mainPanel.add(priceTextField);
            mainPanel.add(calculateButton);
            mainPanel.add(outputScrollPane);
            
            //add the listeners
            priceTextField.addActionListener(this);
            calculateButton.addActionListener(this);
                    
            //add the panel to the frame
            add(mainPanel);
            setSize(300,400);
            setVisible(true);
    	}
    	
    	
    	public void actionPerformed(ActionEvent evt)
    	{
    		getInput();
    		clear();
    	}
    
    	public void getInput()
    	{
    		nameString = bookNameTextField.getText();
    		quantityInteger = Integer.parseInt(quantityTextField.getText());
    		priceDouble = Double.parseDouble(priceTextField.getText());
    		
    		Calculation myCalcs = new Calculation(quantityInteger, priceDouble);
    		displayOutput(myCalcs.getQuantity());
    
    	}
    	public void displayOutput(double CalculationDouble) 
        {
            Calculation myOrder = new Calculation();
    		//object to format to currency
            DecimalFormat formatDecimalFormat = new DecimalFormat("$0.00");
            DecimalFormat formatNumberFormat = new DecimalFormat("0");
            //variables to store the retrieved values from the calculation class
            double  priceDouble, subTotalDouble, shippingDouble, taxDouble, totalDouble, 
            grandTotalDouble;
            int totalNumberOfOrdersInteger;
                    
            priceDouble = myOrder.getPrice();
            subTotalDouble = myOrder.getSubTotal();
            shippingDouble = myOrder.getShipping();
            taxDouble = myOrder.getTax();
            totalDouble = myOrder.getTotal();
            grandTotalDouble = myOrder.getGrandTotal();
            totalNumberOfOrdersInteger = myOrder.getNumberOfOrders();
            
            //display output
            outputTextArea.append('\n' + "Name of the Book: " + nameString + '\n' + 
            		"Quantity Ordered: " + formatNumberFormat.format(quantityInteger)
            		+ '\n' + "Price: 	" + formatDecimalFormat.format(priceDouble)+ '\n'
            		+ '\n' + "Subtotal: 	" + formatDecimalFormat.format(subTotalDouble)
            		+ '\n' + "Shipping: 	" + formatDecimalFormat.format(shippingDouble)
            		+ '\n' + "Tax: 	" + formatDecimalFormat.format(taxDouble) + '\n'+ 
            		"Total:	" +	formatDecimalFormat.format(totalDouble) + '\n' +'\n' + 
            		"Total Quantity To-Date: " + totalNumberOfOrdersInteger + '\n' + 
            		" Grand Total To-Date: " + formatDecimalFormat.format(grandTotalDouble)
            		+ '\n');      
        }
       
        public void  clear()
        {
        	//clear existing text from text fields and request cursor to top
        	bookNameTextField.setText("");
            quantityTextField.setText("");
            priceTextField.setText("");
            bookNameTextField.requestFocus();        
        }    
    }

  2. #2
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    Please post the Calculation() class

  3. #3
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    Here you go!!

    Java Code:
    public class Calculation 
    {
    	private double priceDouble, subTotalDouble, taxDouble, 
    	shippingDouble, totalDouble;
    	private int quantityInteger;
    	private static double grandTotalDouble;
    	private static int totalNumberOfOrdersInteger;
    	
    	public Calculation()
    	{
    	
    	}
    	
    	public Calculation(int quantityNewInteger, double priceNewDouble)
    	{
    		setQuantity(quantityNewInteger);
    		setPrice(priceNewDouble);
    		calculate();
    	}
    	
    	private void setQuantity(int quantityNewInteger)
    	{
    		//assign public variable to private
    		quantityInteger = quantityNewInteger;
    	}
    	private void setPrice(double priceNewDouble)
    	{
    		//assign public variable to private
    		priceDouble = priceNewDouble;
    	}
    	private void calculate()
    	{
    		final int SHIPPING_RATE_INTEGER = 1;
    		final double TAX_RATE_DOUBLE = 0.0825;
    		
    		
    		//calculate the subTotal of the order
    		subTotalDouble = quantityInteger * priceDouble;
    		//calculate the shipping of the order
    		shippingDouble = SHIPPING_RATE_INTEGER * quantityInteger;
    		//calculate the Tax of the order
    		taxDouble = subTotalDouble * TAX_RATE_DOUBLE;
    		//calculate the Total including shipping and tax of the order
    		totalDouble = taxDouble + subTotalDouble + shippingDouble;
    		// calculate the total of all orders
    		//and the number of orders processed
    		grandTotalDouble += totalDouble;
    		totalNumberOfOrdersInteger++;
    		
    	}
    	
    	public double getQuantity()
    	{
    		//returning quantity
    		return quantityInteger;
    		
    	}
    	
    	public double getPrice()
    	{
    		//returning price
    		return priceDouble;
    	}
    	
    	public double getSubTotal()
    	{
    		//returning subTotal
    		return subTotalDouble;
    		
    	}
    	
    	public double getShipping()
    	{
    		//returning shipping
    		return shippingDouble;
    		
    	}
    	
    	public double getTax()
    	{
    		//returning Tax
    		return taxDouble;
    		
    	}
    	
    	public double getTotal()
    	{
    		//returning grand total of orders
    		return totalDouble;
    	}
    	
    	public double getGrandTotal()
    	{
    		//returning grand total of orders
    		return grandTotalDouble;
    	}
    	
    	public int getNumberOfOrders()
    	{
    		//return total number of orders processed
    		return totalNumberOfOrdersInteger;
    	}	
    }

  4. #4
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    here it is. I didnt change anything in your Calculation Class. I only modify the main class.

    Java Code:
    import java.text.DecimalFormat;
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.event.*;
    
    
    public class Main extends JFrame implements ActionListener
    {   private Calculation myOrder = new Calculation();
    	 // All the GUI objects
        JPanel mainPanel = new JPanel();
        JLabel storeLabel = new JLabel("       OrderBook INC.         ");
        JTextField bookNameTextField = new JTextField(20);
        JTextField quantityTextField = new JTextField(20);
        JTextField priceTextField = new JTextField(20);
        JButton calculateButton = new JButton(" Calculate   ");
        JTextArea outputTextArea = new JTextArea("Books Ordered", 10, 25);
        JScrollPane outputScrollPane = new JScrollPane(outputTextArea);
    	
    	int quantityInteger;
    	double priceDouble;
    	String nameString;
    	
        //object of the font
        Font storeFont = new Font("Arial",Font.BOLD,14);
    
    	public static void main(String[] args)
    	{
    		Main myBooks = new Main();
    		myBooks.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    	}
    	
    	public Main()
    	{
    		designFrame();
    		
    	}
    	
    	
    	public void designFrame()
    	{
            //set the font and the color
            storeLabel.setFont(storeFont);
            storeLabel.setForeground(Color.GRAY);
            
                    //add the listeners
    //        priceTextField.addActionListener(this);
            calculateButton.addActionListener(this);
        
            //add the components to the mainPanel
            mainPanel.add(storeLabel);
            mainPanel.add(new JLabel("       Book Name            "));
            mainPanel.add(bookNameTextField);
            mainPanel.add(new JLabel("    Quantity Ordered   "));
            mainPanel.add(quantityTextField);
            mainPanel.add(new JLabel("    Price       "));
            mainPanel.add(priceTextField);
            mainPanel.add(calculateButton);
            mainPanel.add(outputScrollPane);
            
    
                    
            //add the panel to the frame
            add(mainPanel);
            setSize(300,400);
            setVisible(true);
    	}
    	
    	
    	public void actionPerformed(ActionEvent evt)
    	{ String cmd = evt.getActionCommand();
              if (cmd.equalsIgnoreCase(" Calculate   ")){
                  nameString = bookNameTextField.getText();
    	      quantityInteger = Integer.parseInt(quantityTextField.getText());
    	      priceDouble = Double.parseDouble(priceTextField.getText());
                  myOrder.Calculation(quantityInteger, priceDouble);
                  displayOutput();
              }
    
    	clear();
    	}
    	public void displayOutput() 
        {
            
    		//object to format to currency
            DecimalFormat formatDecimalFormat = new DecimalFormat("$0.00");
            DecimalFormat formatNumberFormat = new DecimalFormat("0");
            //variables to store the retrieved values from the calculation class
            double  priceDouble, subTotalDouble, shippingDouble, taxDouble, totalDouble, 
            grandTotalDouble;
            int totalNumberOfOrdersInteger;
              
            priceDouble = myOrder.getPrice(); System.out.println(priceDouble);
            subTotalDouble = myOrder.getSubTotal();
            shippingDouble = myOrder.getShipping();
            taxDouble = myOrder.getTax();
            totalDouble = myOrder.getTotal();
            grandTotalDouble = myOrder.getGrandTotal();
            totalNumberOfOrdersInteger = myOrder.getNumberOfOrders();
            
            //display output
            outputTextArea.append('\n' + "Name of the Book: " + nameString + '\n' + 
            		"Quantity Ordered: " + formatNumberFormat.format(quantityInteger)
            		+ '\n' + "Price: 	" + formatDecimalFormat.format(priceDouble)+ '\n'
            		+ '\n' + "Subtotal: 	" + formatDecimalFormat.format(subTotalDouble)
            		+ '\n' + "Shipping: 	" + formatDecimalFormat.format(shippingDouble)
            		+ '\n' + "Tax: 	" + formatDecimalFormat.format(taxDouble) + '\n'+ 
            		"Total:	" +	formatDecimalFormat.format(totalDouble) + '\n' +'\n' + 
            		"Total Quantity To-Date: " + totalNumberOfOrdersInteger + '\n' + 
            		" Grand Total To-Date: " + formatDecimalFormat.format(grandTotalDouble)
            		+ '\n');      
            return;
        }
       
        public void  clear()
        {
        	//clear existing text from text fields and request cursor to top
        	bookNameTextField.setText("");
            quantityTextField.setText("");
            priceTextField.setText("");
            bookNameTextField.requestFocus();        
        }    
    }
    I hope that helps. -Eku

  5. #5
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    Thanks, but I cannot use an if statement for this project. :(

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  7. #7
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    It's a requirement for the project. I guess there is a more simpler way to do it. I just can't seem to think of it.

  8. #8
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    Here you go. No more If statement.

    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package test;
    import java.text.DecimalFormat;
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.event.*;
    
    
    public class Main extends JFrame implements ActionListener
    {   private Calculation myOrder = new Calculation();
    	 // All the GUI objects
        JPanel mainPanel = new JPanel();
        JLabel storeLabel = new JLabel("       OrderBook INC.         ");
        JTextField bookNameTextField = new JTextField(20);
        JTextField quantityTextField = new JTextField(20);
        JTextField priceTextField = new JTextField(20);
        JButton calculateButton = new JButton(" Calculate   ");
        JTextArea outputTextArea = new JTextArea("Books Ordered", 10, 25);
        JScrollPane outputScrollPane = new JScrollPane(outputTextArea);
    	
    	int quantityInteger;
    	double priceDouble;
    	String nameString;
    	
        //object of the font
        Font storeFont = new Font("Arial",Font.BOLD,14);
    
    	public static void main(String[] args)
    	{
    		Main myBooks = new Main();
    		myBooks.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    	}
    	
    	public Main()
    	{
    		designFrame();
    		
    	}
    	
    	
    	public void designFrame()
    	{
            //set the font and the color
            storeLabel.setFont(storeFont);
            storeLabel.setForeground(Color.GRAY);
            
                    //add the listeners
            calculateButton.addActionListener(this);
        
            //add the components to the mainPanel
            mainPanel.add(storeLabel);
            mainPanel.add(new JLabel("       Book Name            "));
            mainPanel.add(bookNameTextField);
            mainPanel.add(new JLabel("    Quantity Ordered   "));
            mainPanel.add(quantityTextField);
            mainPanel.add(new JLabel("    Price       "));
            mainPanel.add(priceTextField);
            mainPanel.add(calculateButton);
            mainPanel.add(outputScrollPane);
            
    
                    
            //add the panel to the frame
            add(mainPanel);
            setSize(300,400);
            setVisible(true);
    	}
    	
    	
    	public void actionPerformed(ActionEvent evt)
    	{ 
                  nameString = bookNameTextField.getText();
    	      quantityInteger = Integer.parseInt(quantityTextField.getText());
    	      priceDouble = Double.parseDouble(priceTextField.getText());
                  myOrder.Calculation(quantityInteger, priceDouble);
                  displayOutput();
              
    
    	clear();
    	}
    	public void displayOutput() 
        {
            
    		//object to format to currency
            DecimalFormat formatDecimalFormat = new DecimalFormat("$0.00");
            DecimalFormat formatNumberFormat = new DecimalFormat("0");
            //variables to store the retrieved values from the calculation class
            double  priceDouble, subTotalDouble, shippingDouble, taxDouble, totalDouble, 
            grandTotalDouble;
            int totalNumberOfOrdersInteger;
              
            priceDouble = myOrder.getPrice(); System.out.println(priceDouble);
            subTotalDouble = myOrder.getSubTotal();
            shippingDouble = myOrder.getShipping();
            taxDouble = myOrder.getTax();
            totalDouble = myOrder.getTotal();
            grandTotalDouble = myOrder.getGrandTotal();
            totalNumberOfOrdersInteger = myOrder.getNumberOfOrders();
            
            //display output
            outputTextArea.append('\n' + "Name of the Book: " + nameString + '\n' + 
            		"Quantity Ordered: " + formatNumberFormat.format(quantityInteger)
            		+ '\n' + "Price: 	" + formatDecimalFormat.format(priceDouble)+ '\n'
            		+ '\n' + "Subtotal: 	" + formatDecimalFormat.format(subTotalDouble)
            		+ '\n' + "Shipping: 	" + formatDecimalFormat.format(shippingDouble)
            		+ '\n' + "Tax: 	" + formatDecimalFormat.format(taxDouble) + '\n'+ 
            		"Total:	" +	formatDecimalFormat.format(totalDouble) + '\n' +'\n' + 
            		"Total Quantity To-Date: " + totalNumberOfOrdersInteger + '\n' + 
            		" Grand Total To-Date: " + formatDecimalFormat.format(grandTotalDouble)
            		+ '\n');      
            return;
        }
       
        public void  clear()
        {
        	//clear existing text from text fields and request cursor to top
        	bookNameTextField.setText("");
            quantityTextField.setText("");
            priceTextField.setText("");
            bookNameTextField.requestFocus();        
        }    
    }
    ^_^ Why are restricted from using the If statement?

  9. #9
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    There are lots of simplier way to do this. You just need some time to figure it out. =)

  10. #10
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    Java Code:
    public void actionPerformed(ActionEvent evt)
    { 
                nameString = bookNameTextField.getText();
                quantityInteger = Integer.parseInt(quantityTextField.getText());
                priceDouble = Double.parseDouble(priceTextField.getText());
                myOrder.[U][B]Calculation[/B][/U](quantityInteger, priceDouble);
                displayOutput();
    The method Calculation is undefined for the type Calculation is the error that im getting now.

  11. #11
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    Hmmmm. . . It works fine here. I didnt change anything in your Calculation Class. Did you change anything in your Calculation Class? I used the Calculation Class you have posted.

  12. #12
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    Can you post what the error is?

  13. #13
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
    The method Calculation(int, double) is undefined for the type Calculation at Main.actionPerformed(Main.java:75)
    at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source) at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Those are the errors. Thanks

  14. #14
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    hehehe. I got it. Please change your Calculation to this one:

    Java Code:
    public void Calculation(int quantityNewInteger, double priceNewDouble)
    	{
    		setQuantity(quantityNewInteger);
    		setPrice(priceNewDouble);
    		calculate();
    	}

  15. #15
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    Java Code:
    import javax.swing.*;
    import javax.swing.JTextField;
    import java.awt.event.*;
    import java.text.*;
    import java.awt.*;
     
    public class Main extends JFrame implements ActionListener 
    {
        // All the GUI objects
        JPanel mainPanel = new JPanel();
        JLabel storeLabel = new JLabel("       OrderBook INC.         ");
        JTextField bookNameTextField = new JTextField(20);
        JTextField quantityTextField = new JTextField(20);
        JTextField priceTextField = new JTextField(20);
        JButton calculateButton = new JButton(" Calculate   ");
        JTextArea outputTextArea = new JTextArea("Books Ordered", 10, 25);
        JScrollPane outputScrollPane = new JScrollPane(outputTextArea);
            
        //object of the font
        Font storeFont = new Font("Arial",Font.BOLD,14);
              
        public static void main(String[] args) 
        {
            //create an object of the class and code the close button
            Main myBooks = new Main();
            myBooks.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            
        }
        
        public Main() 
        {
            designFrame();
            
        }
        
        public void designFrame() 
        {
            //set the font and the color
            storeLabel.setFont(storeFont);
            storeLabel.setForeground(Color.GRAY);
        
            //add the components to the mainPanel
            mainPanel.add(storeLabel);
            mainPanel.add(new JLabel("       Book Name            "));
            mainPanel.add(bookNameTextField);
            mainPanel.add(new JLabel("    Quantity Ordered   "));
            mainPanel.add(quantityTextField);
            mainPanel.add(new JLabel("    Price       "));
            mainPanel.add(priceTextField);
            mainPanel.add(calculateButton);
            mainPanel.add(outputScrollPane);
            
            //add the listeners
            priceTextField.addActionListener(this);
            calculateButton.addActionListener(this);
                    
            //add the panel to the frame
            add(mainPanel);
            setSize(300,400);
            setVisible(true);
        }
        
        public void actionPerformed(ActionEvent evt)
        
        {
            getInput();
            clear();        
        
        }
        
        //declaring local variables    	
    	double quantityDouble, priceDouble;
    	Calculation myOrder;
    	String nameString;
    
        public void getInput() 
        {  	         	
            // get input
            quantityDouble = Double.parseDouble(quantityTextField.getText());
            priceDouble = Double.parseDouble(priceTextField.getText());
            nameString = bookNameTextField.getText();
        
            //send the input the calculation class
            myOrder = new Calculation(quantityDouble, priceDouble);
            displayOutput(myOrder.getQuantity());
        }
        
        public void displayOutput(double CalculationDouble) 
        {
            //object to format to currency
            DecimalFormat formatDecimalFormat = new DecimalFormat("$0.00");
            DecimalFormat formatNumberFormat = new DecimalFormat("0");
            //variables to store the retrieved values from the calculation class
            double priceDouble, subTotalDouble, shippingDouble, taxDouble, totalDouble, 
            grandTotalDouble;
            int totalNumberOfOrdersInteger;
                    
            priceDouble = myOrder.getPrice();
            subTotalDouble = myOrder.getSubTotal();
            shippingDouble = myOrder.getShipping();
            taxDouble = myOrder.getTax();
            totalDouble = myOrder.getTotal();
            grandTotalDouble = myOrder.getGrandTotal();
            totalNumberOfOrdersInteger = myOrder.getNumberOfOrders();
            
            //display output
            outputTextArea.append('\n' + "Name of the Book: " + nameString + '\n' + 
            		"Quantity Ordered: " + formatNumberFormat.format(quantityDouble)
            		+ '\n' + "Price: 	" + formatDecimalFormat.format(priceDouble)+ '\n'
            		+ '\n' + "Subtotal: 	" + formatDecimalFormat.format(subTotalDouble)
            		+ '\n' + "Shipping: 	" + formatDecimalFormat.format(shippingDouble)
            		+ '\n' + "Tax: 	" + formatDecimalFormat.format(taxDouble) + '\n'+ 
            		"Total:	" +	formatDecimalFormat.format(totalDouble) + '\n' +'\n' + 
            		"Total Quantity To-Date: " + totalNumberOfOrdersInteger + '\n' + 
            		" Grand Total To-Date: " + formatDecimalFormat.format(grandTotalDouble)
            		+ '\n');      
        }
       
        public void  clear()
        {
        	//clear existing text from text fields and request cursor to top
        	bookNameTextField.setText("");
            quantityTextField.setText("");
            priceTextField.setText("");
            bookNameTextField.requestFocus();        
        }    
    }
    I orginally did it this way and everything worked, but was told that the object is not private

  16. #16
    crazydeo is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    Thank you sooo much!

  17. #17
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    No Problem my friend. . . =)

  18. #18
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    You can now mark this thread as SOLVED... :)
    freedom exists in the world of ideas

Similar Threads

  1. Output Redirection
    By Sixtease in forum New To Java
    Replies: 8
    Last Post: 12-29-2008, 10:18 AM
  2. Why the output is always zero
    By mehrotra.chitij in forum New To Java
    Replies: 12
    Last Post: 04-25-2008, 04:05 AM
  3. How to redirect the output
    By Java Tip in forum java.io
    Replies: 0
    Last Post: 04-04-2008, 02:36 PM
  4. output
    By Camden in forum New To Java
    Replies: 3
    Last Post: 12-01-2007, 10:34 PM
  5. get the output from whoami
    By gary in forum Advanced Java
    Replies: 2
    Last Post: 06-12-2007, 01:05 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
  •