-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dealership_Project.java
84 lines (74 loc) · 3.22 KB
/
Dealership_Project.java
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Prajeet Bohara
* 12/13/2023
* P3: Dealership Project
*/
import java.util.*;
public class Dealership_Project {
public static void main(String[] args) {
Scanner inscan = new Scanner(System.in);
System.out.println("Welcome to car Dealership!!");
System.out.println("Type 'a' to buy a car!");
System.out.println("Type 'b' to sell a car!");
String entry = inscan.nextLine();
//***********USING IF-ELSE-METHOD**************
//****You can also do this using CASE method***
if (entry.equals("a")){
System.out.println("You choose to buy a car!");
System.out.println("What is your budget?");
int budget = inscan.nextInt();
if (budget >= 10000){
System.out.println("Great! Hyundai Elantra is available for.");
System.out.println("Do you have insurance? Write 'yes' or 'no'");
inscan.nextLine();
String insurance = inscan.nextLine();
if(insurance.equals("yes")){
System.out.println("Do you have a license? Write 'yes' or 'no.'");
String License = inscan.nextLine();
if(License.equals("yes")){
System.out.println("What is your credit score?");
int creditScore = inscan.nextInt();
if(creditScore > 660){
System.out.println("Congratulations! you are approved! Pleasure doing business with you!");
}
else{
System.out.println("We're sorry. You are not eligible.");
}
}
else if (License.equals("no")){
System.out.println("We're sorry. You are not eligible.");
}else{
System.out.println("Invalid Input");
}
}
else if ( insurance.equals("no")){
System.out.println("We're sorry. You are not eligible.");
}
else{
System.out.println("Invalid input");
}
}
else{
System.out.println("We're sorry. You are not eligible.");
}
}
else if (entry.equals("b")){
System.out.println("You choose to sell a car!");
System.out.println("What is your car valued at?");
int value = inscan.nextInt();
System.out.println("What is selling price?");
int price = inscan.nextInt();
inscan.close();
if (value > price && price < 30000){
System.out.println("We are interested. Pleasure doing business with you!");
}
else{
System.out.println("Sorry, we are not interested");
}
}
else{
System.out.println("Invalid entry "+entry);
}
}
}
//**********USING SWITCH METHOD********