-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscount.java
More file actions
40 lines (29 loc) · 875 Bytes
/
Copy pathDiscount.java
File metadata and controls
40 lines (29 loc) · 875 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
38
39
40
package ifStatement;
import java.io.DataInputStream;
import java.io.IOException;
public class Discount {
@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException{
DataInputStream input = new DataInputStream(System.in);
double cost,finalPrice=0;
//ask for total cost
System.out.print("Please input your total cost of the purchase");
cost=Double.parseDouble(input.readLine());
//if the total cost is less than zero
if(cost<=0)
{
System.out.println("Your total cost in invaild");
}
else if(cost<10.0)
{
System.out.println("You are not entitled to recieve a discount");
finalPrice=cost;
}
else
{
System.out.println("You will receive a 10% discount on your purchase");
finalPrice=cost*0.9;
}
System.out.print("Your final cost is: "+finalPrice);
}
}