44 lines
1.1 KiB
Java
44 lines
1.1 KiB
Java
import java.util.Locale;
|
|
import java.util.Scanner;
|
|
|
|
public class Problem09Lanchonete {
|
|
|
|
public static void main(String[] args) {
|
|
Locale.setDefault(Locale.US);
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
System.out.print("Codigo do produto comprado: ");
|
|
int code = sc.nextInt();
|
|
|
|
System.out.print("Quantidade comprada: ");
|
|
int quantity = sc.nextInt();
|
|
|
|
double price;
|
|
switch (code) {
|
|
case 1:
|
|
price = 5.00;
|
|
break;
|
|
case 2:
|
|
price = 3.50;
|
|
break;
|
|
case 3:
|
|
price = 4.80;
|
|
break;
|
|
case 4:
|
|
price = 8.90;
|
|
break;
|
|
case 5:
|
|
price = 7.32;
|
|
break;
|
|
default:
|
|
System.out.println("Codigo de produto invalido!");
|
|
price = 0.0;
|
|
break;
|
|
}
|
|
|
|
double total = price * quantity;
|
|
System.out.printf("Valor a pagar: R$ %.2f%n", total);
|
|
|
|
sc.close();
|
|
}
|
|
} |