-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExerciseFour.java
More file actions
37 lines (23 loc) · 949 Bytes
/
Copy pathExerciseFour.java
File metadata and controls
37 lines (23 loc) · 949 Bytes
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
package UnitTwo;
import java.util.Scanner;
public class ExerciseFour {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Price: ");
double price = scanner.nextDouble();
System.out.println("Quantity: ");
int quantity = scanner.nextInt();
if (100 <= quantity && quantity < 120){
System.out.println("The revenue from sale: " + (price*quantity*(1-0.15)));
System.out.println("Discount: " + (price*quantity*0.15));
}else {
if(quantity >= 120){
System.out.println("The revenue from sale: " + (price*quantity*(1-0.20)));
System.out.println("Discount: " + (price*quantity*0.20));
}else {
System.out.println("The revenue from sale: "+(price*quantity));
System.out.println("Discount: 0");
}
}
}
}