-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicleInsurance.java
More file actions
41 lines (40 loc) · 1.15 KB
/
VehicleInsurance.java
File metadata and controls
41 lines (40 loc) · 1.15 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
import java.util.*;
class VehicleInsurance {
public static void main(String[] args) {
System.out.println("Quel véhicule possédez-vous ? ");
System.out.println("Choix : Voiture, Camion, Bus, Moto");
Scanner scan = new Scanner(System.in);
String choixVehicule = scan.nextLine();
int tarifAssurance = 0;
switch(choixVehicule){
case "Voiture":
tarifAssurance = 100;
break;
case "Camion":
tarifAssurance = 200;
break;
case "Bus":
tarifAssurance = 300;
break;
case "Moto":
System.out.println("Quelle puissance à votre moto ?");
System.out.println("Faible (1), Moyenne (2), Forte (3)");
String puissanceMoto = scan.nextLine();
int puissanceMotoInt = Integer.parseInt(puissanceMoto);
switch(puissanceMotoInt){
case 1 :
tarifAssurance = 100;
break;
case 2 :
tarifAssurance = 200;
break;
case 3 :
tarifAssurance = 300;
break;
default :
System.out.println("Puissance non reconnue");
}
}
System.out.println("Votre assurance vous coûtera : " + tarifAssurance +"€");
}
}