-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShop_Corrected.java
93 lines (90 loc) · 2.68 KB
/
Shop_Corrected.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
85
86
87
88
89
90
91
92
93
import java.io.*;
class Shop_Corrected
{
String name,address;
int type , amount;
double discount , netamt;
public static void main()throws IOException
{
Shop_Corrected Ob=new Shop_Corrected();
Ob.input ();
Ob. calc ();
Ob. output ();
}
void input ()throws IOException
{
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(read);
System.out.println(" ******************** ");
System.out.println("Enter details");
System.out.println(" Enter Name");
name =stdin.readLine();
System.out.println(" Enter Address");
address = stdin.readLine();
System.out.println("Enter amount of purchase");
amount = Integer.parseInt(stdin.readLine());
System.out.println("type of purchase");
System.out.println("1---> Laptop");
System.out.println(" 2--> Desktop");
System.out.println("type:");
type= Integer.parseInt(stdin.readLine());
}
void calc ()
{
switch(type)
{
case 1:
if ( amount <25000)
{
discount = 0*amount;
netamt = amount - discount;
}
if ( amount >2500 && amount >57000)
{
discount = 0.05*amount;
netamt= amount - discount;
}
if(amount >57000 && amount < 100000)
{
discount = 0.075*amount;
netamt = amount - discount;
}
if( amount >100000)
{
discount= 0.01*amount;
netamt= amount- discount;
}
break;
case 2:
if ( amount <25000)
{
discount= 0.05*amount;
netamt= amount- discount;
}
if( amount >25000 && amount<57000)
{
discount= 0.075*amount;
netamt= amount - discount;
}
if(amount >57000 && amount<100000)
{
discount = 0.01*amount;
netamt= amount - discount;
}
if(amount >100000)
{
discount = 0.015*amount;
netamt= amount- discount;
}
break;
}
}
void output()
{
System.out.println("***********************");
System.out.println("Name " +name);
System.out.println("Address " +address);
System.out.println("Net Amount " +netamt);
System.out.println("Thanks for purchasing .\nHope to see you again soon...\nShreshtha Dandnayak ");
}
}