-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer21.java
More file actions
55 lines (36 loc) · 1.06 KB
/
Exer21.java
File metadata and controls
55 lines (36 loc) · 1.06 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
package com.laiane.cursojava.aula15;
import java.util.Scanner;
public class Exer21 {
private static double precoAlc;
public static void main(String[] args) {
try (Scanner scan = new Scanner(System.in)) {
System.out.println("Entre com a quantidade de litros vendidos");
double Litros = scan.nextDouble();
System.out.println("Entre com o tipo de combustivel");
String tipo = scan.next();
double precoGas = 2.5;
double precoAlc = 1.9;
int percDesconto = 0;
double total = 0;
double totalDesco = 0;
if (tipo.equalsIgnoreCase("a")){
if (Litros <= 20){
percDesconto = 3;
} else {
percDesconto = 5;
}
total = Litros * precoAlc;
} else if (tipo.equalsIgnoreCase("g")){
if (Litros <= 20){
percDesconto = 4;
} else {
percDesconto = 6;
}
total = Litros * precoGas;
}
totalDesco = (total / 100) * percDesconto;
double precoAPagar = total - totalDesco;
System.out.println("Valor a ser pago: " + precoAPagar);
}
}
}