-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedif.java
More file actions
38 lines (32 loc) · 1.06 KB
/
Nestedif.java
File metadata and controls
38 lines (32 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
package src;
import java.util.Scanner;
public class Nestedif {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
boolean isStudent;
boolean isFemale;
double price = 999;
System.out.print("Are You A Student? (true/false): ");
isStudent = scanner.nextBoolean();
System.out.print("Are You A Female? (true/false): ");
isFemale = scanner.nextBoolean();
if(isStudent){
if(isFemale) {
System.out.println("You get 20% off for student");
System.out.println("You get 10% off for female");
price *= 0.7;
}else{
System.out.println("You get 10% off");
price *= 0.9;
}
}else if (isFemale) {
System.out.println("You get 10% off for female");
price *= 0.9;
}
else{
System.out.println("No discount for you");
price *= 1;
}
System.out.printf("Final price: ₹%.2f", price);
}
}