Results 1 to 6 of 6
  1. #1
    Yappie is offline Member
    Join Date
    Jul 2013
    Posts
    11
    Rep Power
    0

    Default How to put if statement and Int on this problem



    Program should decline if you put an invalid money bill.

    Ex: Int = 20,50,100,200,500,1000; Php Bills

    How do i put int and if statement on this??

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,187
    Blog Entries
    7
    Rep Power
    24

    Default Re: How to put if statement and Int on this problem

    I don't understand one bit from that image: in the 'General Output' pane is says 'P for Lays and X for Exit' and you enter a 'C' and the program happily continues; next time please show us your real code instead of a snapshot of (part of) your code; it is confusing at best.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,100
    Rep Power
    8

    Default Re: How to put if statement and Int on this problem

    What does your Java book tell you to do?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Yappie is offline Member
    Join Date
    Jul 2013
    Posts
    11
    Rep Power
    0

    Default Re: How to put if statement and Int on this problem

    Quote Originally Posted by JosAH View Post
    I don't understand one bit from that image: in the 'General Output' pane is says 'P for Lays and X for Exit' and you enter a 'C' and the program happily continues; next time please show us your real code instead of a snapshot of (part of) your code; it is confusing at best.

    kind regards,

    Jos
    sorry about that here's my code

    Java Code:
    import java.util.Scanner;
    	public class YapVendo{
    		public static void main(String[] args){
    	Scanner read = new Scanner(System.in);
    
    	System.out.println("Vending Machine");
    	System.out.println("===============");
    	System.out.println("A For Chippy Small 		Php 15.00");
    	System.out.println("B For Chippy Big 		Php 29.00");
    	System.out.println("C For Kitkat(Single) 	Php 20.00");
    	System.out.println("D For Kitkat(Double) 	Php 38.00");
    	System.out.println("E For Tortillas(Small) 	Php 16.00");
    	System.out.println("F For Tortillas(Big) 	Php 31.00");
    	System.out.println("G For Cheeze Rings 		Php 12.00");
    	System.out.println("H For Sneakers Bar 		Php 40.00");
    	System.out.println("I For Choco Nut 		Php 13.00");
    	System.out.println("J For Nagaraya(Small) 	Php 14.00");
    	System.out.println("K For Nagaraya(Big) 	Php 27.00");
    	System.out.println("L For Mars 				Php 42.00");
    	System.out.println("M For Milo Choco Bars 	Php 36.00");
    	System.out.println("N For Busog Lusog 		Php 11.00");
    	System.out.println("O For Nesvita 			Php 18.00");
    	System.out.println("P For Lays 				Php 65.00");
    	System.out.println("X For Exit");
    	System.out.println("Enter Choice: ");
    	char ch = read.nextLine(). charAt(0);
    	if(ch=='A'){
    
    		System.out.println("Choice Chippy(Small) Price is Php27.00");
    
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin:");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-27;
    		System.out.println("Bill Slot:"+First);
    		System.out.println("Coin Slot:"+Second);
    		System.out.println("Payment Given is:"+Sum);
    		System.out.println("Enjoy Your Chippy(Small) purchase");
    		System.out.println("Your Change is:"+chippy);
    	}
    	if(ch=='B'){
    
    		System.out.println("Choice Chippy(Big) Price is Php29.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-29;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Chippy(Big) Purchase");
    			System.out.print("Your Change is:"+chippy);
    	}
    	if(ch=='C'){
    
    		System.out.println("Choice Kitkat(Single) Price is Php20.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("We Only Accept Php Bills");
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-20;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Kitkat(Single) Purchase");
    			System.out.print("Your Change is:"+chippy);
    	}
    	if(ch=='D'){
    
    		System.out.println("Choice Kitkat(Double) Price is Php38.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-38;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Kitkat(Double) Purchase");
    			System.out.print("Your Change is:"+chippy);
    	}
    		if(ch=='E'){
    			System.out.println("Choice Tortillas(Small) Price is Php16.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-16;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Tortillas(Small) Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='F'){
    			System.out.println("Choice Tortillias(Big) Price is Php31.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-31;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Tortillias(Big) Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='G')
    		{
    			System.out.println("Choice Cheeze Rings Price is Php12.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-12;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Cheeze Rings) Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='H'){
    			System.out.println("Choice Sneakers Bar Price is Php40.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-40;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Sneakers Bar Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='I'){
    			System.out.println("Choice Choco Nut Price is Php13.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-13;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Choco Nut Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='J'){
    			System.out.println("Choice Nagaraya(Small) Price is Php14.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-14;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Nagaraya(Small) Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='K'){
    			System.out.println("Choice Nagaraya(Big) Price is Php27.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-27;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Nagaraya(Big) Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='L'){
    			System.out.println("Choice Mars Price is Php42.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-42;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Mars Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='M'){
    			System.out.println("Choice Milo Choco Bar Price is Php36.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-36;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Milo Choco Bar Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='N'){
    			System.out.println("Choice Busog Lusog Price is Php11.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-11;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Busog Lusog Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='O'){
    			System.out.println("Choice Nesvita Price is Php18.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-18;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Nesvita Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    		if(ch=='P'){
    			System.out.println("Choice Lays Price is Php63.00");
    		System.out.println("Pls Enter Bill or Drop Coin");
    		System.out.println("Enter Bill:");
    		int First = read.nextInt();
    		System.out.println("Enter Coin: ");
    		int Second = read.nextInt();
    		int Sum = First+Second;
    		int chippy = Sum-63;
    		System.out.println("Bill Slot:"+First);
    			System.out.println("Coin Slot:"+Second);
    			System.out.println("Payment Given is:"+Sum);
    			System.out.println("Enjoy Your Lays Purchase");
    			System.out.print("Your Change is:"+chippy);
    		}
    	if(ch=='X'){
    		System.exit(0);
    	}
    
    		}
    	}
    Last edited by JosAH; 08-02-2013 at 05:16 PM. Reason: added [code] ... [/code] tags

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,981
    Rep Power
    21

    Default Re: How to put if statement and Int on this problem

    Please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,187
    Blog Entries
    7
    Rep Power
    24

    Default Re: How to put if statement and Int on this problem

    I added those [code] ... [/code] tags for the OP this time ...

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. If statement problem
    By maynn123 in forum New To Java
    Replies: 5
    Last Post: 11-28-2012, 11:01 AM
  2. problem with if statement?
    By cherrychives in forum New To Java
    Replies: 6
    Last Post: 04-25-2012, 02:42 AM
  3. sql statement problem
    By vincentcharrie in forum Eclipse
    Replies: 5
    Last Post: 02-16-2012, 04:41 PM
  4. Problem with if statement
    By SiX in forum New To Java
    Replies: 8
    Last Post: 07-22-2011, 07:49 PM
  5. Please help me with this Problem Statement
    By KMS in forum New To Java
    Replies: 1
    Last Post: 09-22-2008, 08:44 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
  •