Java condicional

This commit is contained in:
2025-11-06 21:40:53 -03:00
commit 9b69ebbed2
14 changed files with 414 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
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();
}
}