-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer23.java
More file actions
68 lines (48 loc) · 1.36 KB
/
Exer23.java
File metadata and controls
68 lines (48 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.laiane.cursojava.aula15;
import java.util.Scanner;
public class Exer23 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Entrecom o tipo da carne:");
System.out.println("1 - file duplo");
System.out.println("2- alcatra");
System.out.println("3 - picanha");
int tipo = scan.nextInt();
System.out.println("Entre com a quantidade (kg):");
double qtd = scan.nextDouble();
double precoKg = 0;
if (tipo == 1){
System.out.println(qtd + "Kg - file duplo");
if (qtd < 5){
precoKg = 4.9;
} else {
precoKg = 5.8;
}
} else if (tipo == 2){
System.out.println(qtd + "Kg - alcatra");
if (qtd < 5){
precoKg = 5.9;
} else {
precoKg = 6.8;
}
} else if (tipo == 3){
System.out.println(qtd + "Kg - picanha");
if (qtd < 5){
precoKg = 6.9;
} else {
precoKg = 7.8;
}
}
double total = qtd * precoKg;
System.out.println(qtd + "Kg * " + precoKg + " = " + total);
System.out.println("Compra no cartão? digite 1 para sim:");
int cartao = scan.nextInt();
if (cartao == 1){
double desconto = total / 100 * 5;
System.out.println("Desconto de : " + desconto);
System.out.println("Valor a pagar: " + (total - desconto));
} else {
System.out.println("Valor a pagar: " + total);
}
}
}