import java.io.*; 
import java.util.*; 
import java.util.Scanner; 

public class cooperativeCanteen60 { 
static Scanner console = new Scanner(System.in); 
static Scanner sc = new Scanner(System.in); 
public static void main(String[]args) { 
//throws java.io.IOException 
{ 
Scanner in = new Scanner (System.in); 

int type; 
int discountRange; 
int discount; 
int customerType; 
int number; 
int rtotal; 
int vtotal; 
int ftotal; 
int mtotal; 
int tcost = 0; 
int tcost2 = 0; 
int order; 
int change; 
int moneyReceived; 
int price; 
int rprice; 
int fprice; 
int vprice; 
int mprice; 
int quantity; 
int rquantity; 
int vquantity; 
int fquantity; 
int mquantity; 

System.out.println("******COOPERATIVE CANTEEN******"); 
System.out.println("1]BudgetMeal"); 
System.out.println("2]RegularMeal"); 
System.out.println("Type of Order: [1 or 2]?"); 
type=console.nextInt(); 
System.out.println("1]Rice,Vegetable,Softdrink = 30.00"); 
System.out.println("2]Rice,Vegetable,Porkchop = 50.00"); 
System.out.println("3]Rice,Chicken,Softdrink = 40.00"); 
System.out.println("4]Rice,Vegetable,Meat,Softdrink = 60.00"); 
System.out.println("Your order is: [1,2,3 or 4]?"); 
order=console.nextInt(); 
System.out.print ("Number of order:"); 
quantity=in.nextInt(); 
System.out.print ("Price per serving:"); 
price=in.nextInt(); 
System.out.print ("Money Received:"); 
moneyReceived=in.nextInt(); 
tcost=quantity*price; 
System.out.println("1]Employee = 5%"); 
System.out.println("2]Student = 20%"); 
System.out.println("3]Drop-by = 0%"); 
System.out.println("Discount: [1,2 or 3]?"); 
discount=console.nextInt(); 
change=console.nextInt(); 

if (type == 1); 
{ 
System.out.println("\n\t*Budget Meal*"); 
switch (order) { 
case 1: 
System.out.println("\tYour order is: Rice,Vegetable,Softdrink"); break; 
case 2: 
System.out.println("\tYour order is: Rice,Vegetable,Porkchop"); break; 
case 3: 
System.out.println("\tYour order is: Rice,Chicken,Softdrink"); break; 
case 4: 
System.out.println("\tYour order is: Rice,Vegetable,Meat,Softdrink"); break;} 
System.out.println("\tNumber of order:"+quantity); 
System.out.println("\tPrice:"+tcost); 
switch (discount) { 
case 1: 
System.out.println("\tDiscount: 5%"); break; 
case 2: 
System.out.println("\tDiscount: 20%"); break; 
case 3: 
System.out.println("\tDiscount: 0%"); break;} 
System.out.println("\tMoney Received:"+moneyReceived); 
switch (change) { 
case 1: 
System.out.println("\tChange:"+(moneyReceived-tcost*0.95)); break; 
case 2: 
System.out.println("\tChange:"+(moneyReceived-tcost*0.80)); break; 
case 3: 
System.out.println("\tChange:"+(moneyReceived-tcost*1)); 
break; 
} 
} 


System.out.print ("Number of rice:"); 
rquantity=in.nextInt(); 
System.out.print ("Price per serving:"); 
rprice=in.nextInt(); 
rtotal=rquantity*rprice; 
System.out.print ("Number of vegetable:"); 
vquantity=in.nextInt(); 
System.out.print ("Price per serving:"); 
vprice=in.nextInt(); 
vtotal=vquantity*vprice; 
System.out.print ("Number of fish:"); 
fquantity=in.nextInt(); 
System.out.print ("Price per serving:"); 
fprice=in.nextInt(); 
ftotal=fquantity*fprice; 
System.out.print ("Number of meat:"); 
mquantity=in.nextInt(); 
System.out.print ("Price per serving:"); 
mprice=in.nextInt(); 
mtotal=mquantity*mprice; 
tcost2=rtotal + vtotal + ftotal + mtotal; 
System.out.print ("Money Received:"); 
moneyReceived=in.nextInt(); 
System.out.println("1]Employee = 5%"); 
System.out.println("2]Student = 20%"); 
System.out.println("3]Drop-by = 0%"); 
System.out.println("Discount: [1,2 or 3]?"); 
discount=console.nextInt(); 
System.out.println("******COOPERATIVE CANTEEN******"); 
change=console.nextInt(); 

if (type == 2); 
{ 
System.out.println("\n\t*Regular Meal*"); 
System.out.println("\tYour order are/is:"); 
System.out.println("\tNumber of rice:"+rquantity); 
System.out.println("\tNumber of vegetable:"+vquantity); 
System.out.println("\tNumber of fish:"+fquantity); 
System.out.println("\tNumber of meat:"+mquantity); 
System.out.println("\tPrice:"+tcost2); 
switch (discount) { 
case 1: 
System.out.println("\tDiscount: 5%"); break; 
case 2: 
System.out.println("\tDiscount: 20%"); break; 
case 3: 
System.out.println("\tDiscount: 0%"); break;} 
System.out.println("\tMoney Received:"+moneyReceived); 
switch (change) { 
case 1: 
System.out.println("\tChange:"+(moneyReceived-tcost2*0.95)); break; 
case 2: 
System.out.println("\tChange:"+(moneyReceived-tcost2*0.80)); break; 
case 3: 
System.out.println("\tChange:"+(moneyReceived-tcost2*1)); 
break;} 
} 
} 
} 
} 

hi guys...please. check the one above... I'm new to java and I need some help in here. I'm having a problem.
My problem is: If I only choose Budget Meal ...that Regular Meal is also showing.. and I can't choose. please help me. Im all messed up. I cant think of any solution. My codes are always showing whichever I choose. You can ask me if you're kinda confused

Edited 3 Years Ago by JavaGr33nh0rn

Line 128 if (type == 2); the semicolon finishes the if statement, so it reads "if type is 2... do nothing". Then the { on the next line just starts an ordinary code block that will be excecuted after the if statement. It's the semicolon that's your problem.
Same problem on line 63. There may be others. I didn't check them all.

Edited 3 Years Ago by JamesCherrill

thanks for that sir... but i still have a problem. If I choose type of order 1 (line 63) it must only display the budget meal... but it also display type 2(regularmeal).. Same goes with type 2. If i choose it, type 1 is still included as if it is a default one... T_T..what must I do?

did you remove all those semicolons?
can you be a bit more specific? what is the value of type, and what is the output printed?

yeah..i did remove it.. In line 41, it asks what type of order.. If my answer is 1(line 63), type 2(line128) is still showing..

yeah..i did remove it

"it"? There were at least two that are wrong. Please don't take this the wrong way, but can you post the corrected version of the line(s) you changed, because it sounds like the origina problem is still there.

Edited 3 Years Ago by JamesCherrill

ehm ... no it isn't?
just ran your code here, you've written it quite complicated and it's not that easy to follow the logic without knowing it, but I don't get that problem here.
can you post the code you have now?

ok...sorry 'bout that.. I lost my homework...the instructions are there. I gotta find it first to make it clear :))

import java.util.*; 

public class HighestLowestDifference2324 { 
public static void main(String[] args) { 
Scanner input = new Scanner(System.in); 

double maxValue = Double.MIN_VALUE; 
double minValue = Double.MAX_VALUE; 
double minValue1 = Double.MAX_VALUE; 
double minValue2 = Double.MAX_VALUE; 

int count = 0; 
double difference = 0; 

System.out.println("Enter numbers. Terminate with Q."); 
while (input.hasNextDouble()) { 

double Value = input.nextDouble(); 

if (Value > maxValue) { 
maxValue = Value; 
} 
if (Value < minValue) { 
minValue = Value; 
} 
if (Value < minValue) { 
minValue1 = Value; } 
if (minValue == minValue1) { 
minValue = Value; } 
if (Value < minValue1) { 
minValue2 = Value; } 
if (minValue1 == minValue2) { 
minValue1 = Value; } 
} 
count++; 
difference = maxValue-minValue; 
{ 
if (count > 0) { 
System.out.println("Highest no. is: " + maxValue); 
System.out.println("Lowest no. is: " + minValue); 
System.out.println("The difference from the highest is: \n" + difference); 
} 
else { 
System.out.println("Have a good day!"); } 
} 
} 
}

the outputs highest and lowest values are fine.. but tere's something wrong in getting the difference.. I must get the difference of the highest number and the low numberS..
ex: numbers given: 1,2,3,4,5
The difference from the highest is:
[5-1]=4
[5-2]=3 <---how can i display them?
[5-3]=2
[5-4]=1

it's like that.. please help me.thanks

I must get the difference of the highest number and the low numberS.. when i ran it, it only shows the difference "4",for example... it must show 3,2, and 1 too

My homework goes like this:
Write a program that accepts as many integers the user wants to input. Determine the highest and lowest numbers and subtract all other numbers from the highest number.
example: numbers to be entered: 6
number1 :15
number2:20
number3:29
number4:38
number5:12
number6: 42

Output:
Highest: 42
Lowest:12
[The difference from the highest is:
[42-15]=27
[42-20]=22 <---how can i display them?
[42-29]=13
[42-38]=4
[42-312]=30

it's like that.. please help me.thanks

Edited 3 Years Ago by JavaGr33nh0rn

well, then you'll need to add a simple loop, but since this is another application, it might have been better if you started another thread for it.

This question has already been answered. Start a new discussion instead.