coffee service in java netbeans
This is a code to order coffee; gives options cappuccino, mocha and red when the option you want digiten show the value of coffee of choice after that payment and asked if you had to spin the says if everything he says is missing, very simple to do.
To show returns in a variable System.out.println puts the payment less the value of the coffee of choice on if this is done then you'll see the code.
Seller This is the Scanner which can request data screen brings.
public
static void main(String[] args) {
Scanner tec = new
Scanner(System.in);
int num1, num2;
int capuccino=10;
int red=30;
int mocha=20;
System.out.println("enter the
coffee you want:");
System.out.println("press 1
for cappuccino, 2 for red, 3 for mocha ");
num1 = tec.nextInt();
num2 = 0;
if (num1 == 1) {
System.out.println("capuccino
voucher 10");
num2 = 1;
} else if (num1 == 2) {
System.out.println("red voucher
30");
num2 = 2;
} else if (num1 == 3) {
System.out.println("mocha voucher
20");
num2 = 3;
}
System.out.println("type your
payment ");
float payment = 01;
double missing =0;
payment = tec.nextFloat();
if (num2 == 1) {
missing =capuccino- payment;
if (missing >0){
System.out.println("lack
money please enter:$"+( missing));
}
else
System.out.println("their
returns are: $" + (payment - 10));
}
else if (num2 == 2) {
missing =red - payment;
if (missing >0){
System.out.println("lack
money please enter:$"+( missing));
}
else
System.out.println("their
returns are: $" + (payment - 30));
}
else if (num2 == 3) {
missing =mocha- payment;
if (missing >0){
System.out.println("lack
money please enter:$"+( missing));
}
else
System.out.println("their
returns are: $" + (payment - 20));
}
}
follow me :D
Comentarios
Publicar un comentario