-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavalab1.java
More file actions
53 lines (49 loc) · 1.88 KB
/
Copy pathjavalab1.java
File metadata and controls
53 lines (49 loc) · 1.88 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
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.Scanner;
class javalab1
{
public static void main(String[] args)
{
Scanner sr = new Scanner(System.in);
double amount = 0, netamount, discount = 0;
String name, address, type;
System.out.print("Name:");
name = sr.nextLine();
System.out.print("Address:");
address = sr.nextLine();
System.out.print("Type(L for laptop and D for desktop):");
type = sr.nextLine();
System.out.print("Amount:");
amount = sr.nextDouble();
if (amount > 0)
{
switch (type)
{
case "L":
if (amount > 0 && amount <= 25000)
discount = (0.0 / 100) * amount;
else if (amount > 25000 && amount <= 57000)
discount = (5.0 / 100) * amount;
else if (amount > 57000 && amount <= 100000)
discount = (7.5 / 100) * amount;
else
discount = (10.0 / 100) * amount;
break;
case "D":
if (amount > 0 && amount <= 25000)
discount = (5.0 / 100) * amount;
else if (amount > 25000 && amount <= 57000)
discount = (7.5 / 100) * amount;
else if (amount > 57000 && amount <= 100000)
discount = (10.0 / 100) * amount;
else
discount = (15.0 / 100) * amount;
break;
}
} else
System.out.println("Enter positive value");
netamount = amount - discount;
System.out.println(
"Customer name:" + name + "\nCustomer address:" + address + "\nAmount to be paid:" + netamount);
sr.close();
}
}