Results 1 to 1 of 1
  1. #1
    waklo99 is offline Member
    Join Date
    Jan 2010
    Posts
    20
    Rep Power
    0

    Default Receipt project....(Beginner plz help)

    Im making a project that will output a receipt... here is the code that ive done so far...
    Java Code:
    import java.io.*;
    
    public class menu{
    	
    	 
    	public String input, choice;
    	public String STShirt;
    	public String SJeans;
    	public String SShorts;
    	
    	
    	public double sum= 0.00;
    	public double TShirt=500.00;
    	public double Jeans= 1000;
    	public double Shorts=300.00;
    	
    	public double SBread=30.00;
    	public double Pork=135.00;
    	public double Chips=6.00;
    	
    	public double Ballpen=5.00;
    	public double Paper=30.00;
    	public double Notebook=50.00;
    	
    	public double TV=20000.00;
    	public double ElectricFan=1000;
    	public double Refregerator=10000;
    	
    	public double Bracelet=300.00;
    	public double Necklace=200.00;
    	public double Ring=200.00;
    	
    	BufferedReader ui = new BufferedReader(new InputStreamReader(System.in));
    	
    	public void Process()throws Exception{
    		Menu1();
    		}
    	
    	
    	
    	public void Menu1()throws Exception{
    	System.out.println("\tmenu\n(1)Clothes\n(2)Groceries\n(3)School Supplies\n(4)Appliances\n(5)Accesories\n(6)Exit");
    		input=ui.readLine();
    		if(input.equals("1"))Clothes();
    		if(input.equals("2"))Groceries();
    		if(input.equals("3"))SchoolSupplies();
    		if(input.equals("4"))Appliances();
    		if(input.equals("5"))Accesories();
    		if(input.equals("6"))exit();
    		if(input!=("1")){System.out.println("choose from 1-6 only!\n\n");Menu1();}
    		}
    	public void Menu2()throws Exception{
    	System.out.println("\tmenu\n(1)Clothes\n(2)Groceries\n(3)School Supplies\n(4)Appliances\n(5)Accesories");
    		input=ui.readLine();
    		if(input.equals("1"))Clothes();
    		if(input.equals("2"))Groceries();
    		if(input.equals("3"))SchoolSupplies();
    		if(input.equals("4"))Appliances();
    		if(input.equals("5"))Accesories();
    		if(input!=("1")){System.out.println("choose from 1-5 only!\n\n");Menu1();}
    		}
    	
    	
    	public void Clothes()throws Exception{
    		
    		System.out.println("\tClothes\n(1)T-Shirt = 500\n(2)Jeans = 1000\n(3)Shorts = 300");
    		input=ui.readLine();
    		if(input.equals("1"))sum+=TShirt;list();
    		if(input.equals("2"))sum+=Jeans;list();
    		if(input.equals("3"))sum+=Shorts;list();
    		if(input!=("1")){System.out.println("choose from 1-3 only!\n\n");Clothes();}
    		}
    	public void Groceries()throws Exception{
    		System.out.println("\tGroceries\n(1)Sliced Bread = 30\n(2)Pork = 135\n(3)Chips = 6");
    		input=ui.readLine();
    		if(input.equals("1")){sum+=SBread;list();}
    		if(input.equals("2")){sum+=Pork;list();}
    		if(input.equals("3")){sum+=Chips;list();}
    		if(input!="1"){System.out.println("choose from 1-3 only!\n\n");Groceries();}
    		}
    	
    	public void SchoolSupplies()throws Exception{
    		System.out.println("\tSchool Supplies\n(1)Ballpen = 5\n(2)Paper = 30\n(3)Notebook = 50");
    		input=ui.readLine();
    		if(input.equals("1")){sum+=Ballpen;list();}
    		if(input.equals("2")){sum+=Paper;list();}
    		if(input.equals("3")){sum+=Notebook;list();}
    		if(input!="1"){System.out.println("choose from 1-3 only!\n\n");Clothes();}
    	}
    	
    	public void Appliances()throws Exception{
    		System.out.println("\tAppliances\n(1)T.V. = 20,000\n(2)Electric Fan = 1,000\n(3)Refregerator = 10,000");
    		input=ui.readLine();
    		if(input.equals("1")){sum+=TV;list();}
    		if(input.equals("2")){sum+=ElectricFan;list();}
    		if(input.equals("3")){sum+=Refregerator;list();}
    		if(input!="1"){System.out.println("choose from 1-3 only!\n\n");Appliances();}
    		}
    	public void Accesories()throws Exception{
    		System.out.println("\tAccesories\n(1)Bracelet = 300\n(2)Necklace = 200\n(3)Ring = 200");
    		input=ui.readLine();
    		if(input.equals("1")){sum+=Bracelet; list();}
    		if(input.equals("2")){sum+=Necklace; list();}
    		if(input.equals("3")){sum+=Ring; list();}
    		if(input!="1"){System.out.println("choose from 1-3 only!\n\n");Accesories();}
    		}
    	public void exit(){
    		System.exit(0);
    		
    	}
    	
    	public void list()throws Exception{
    		System.out.println("\n\n------------------------------\n"+sum+"\n\n\n---------------------------------------------------");
    		do{
    			System.out.println("Buy Another Item?\n(Y)Yes\n(N)No");
    			input=ui.readLine();
    			if(input.equalsIgnoreCase("Y"))Menu2();
    			if(input.equalsIgnoreCase("N"))Menu1();
    			else{System.out.println("choose from 1-2 only!\n\n");list();}
    		}while(true);
    		}
    	
    	
    
    
    }
    can someone give some advice or hints on how i can display:

    the items, prices, cash and change for this...

    example:
    --------------------------
    Receipt:
    Items:

    [1.] T-Shirt = 500
    [2.] Jeans = 1000

    total=1500.00
    --------------------------
    cash = 2000
    change=500


    and also how to make the amount display even if its more than 1,000.00 coz when I choose an item more than 1,000.00 it displays 0.00....

    plz help
    Last edited by waklo99; 03-16-2010 at 07:51 AM.

Similar Threads

  1. Beginner, need a little help
    By jimmy-lin in forum New To Java
    Replies: 6
    Last Post: 10-10-2009, 01:00 AM
  2. beginner here...help please
    By shroomiin in forum New To Java
    Replies: 6
    Last Post: 09-15-2009, 11:06 PM
  3. Beginner needs help!
    By Polyy in forum New To Java
    Replies: 1
    Last Post: 11-27-2008, 05:12 AM
  4. almost done...beginner needs help plz..
    By shongo in forum New To Java
    Replies: 15
    Last Post: 11-10-2008, 08:14 AM

Posting Permissions

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