-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
186 lines (146 loc) · 6.25 KB
/
Copy pathMain.java
File metadata and controls
186 lines (146 loc) · 6.25 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import java.util.Scanner;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Main
{
public static void main(String[] args)
{
Inventory buyInventory = new Inventory();
CalculatePrice total = new CalculatePrice();
Scanner input = new Scanner(System.in);
System.out.println("Welcome to the supply store!");
String linebreak = "~";
int saperator = 1;
int saperatorCount = 25;
while (saperator < saperatorCount) {
System.out.print(linebreak + " ");
saperator++;
if (saperator == saperatorCount)
{
break;
}
}
System.out.print("\n");
DecimalFormat nb = new DecimalFormat("#.##");
System.out.print("notebooks:".toUpperCase()+" "+ "$");
System.out.println(nb.format(buyInventory.noteBooks));
DecimalFormat cal = new DecimalFormat("#.##");
System.out.print("calculators:".toUpperCase()+" "+ "$");
System.out.println(cal.format(buyInventory.calculators));
DecimalFormat bp = new DecimalFormat("#.##");
System.out.print("backpacks:".toUpperCase()+" "+ "$");
System.out.println(bp.format(buyInventory.backPacks));
DecimalFormat blkp = new DecimalFormat("#.##");
System.out.print("blackpens:".toUpperCase()+" "+ "$");
System.out.println(blkp.format(buyInventory.blackPens));
DecimalFormat pl = new DecimalFormat("#.##");
System.out.print("pencils:".toUpperCase()+" "+ "$");
System.out.println(pl.format(buyInventory.pencils));
System.out.println("\n");
int buyNoteBooks = 0;
int buyCalulators = 0;
int buyBackPacks = 0;
int buyBlackpens = 0;
int buyPencils = 0;
double finalPrice = 0;
DecimalFormat fm = new DecimalFormat("#.##");
int completeOrder = 0;
System.out.print("How many Notbooks: ");
while (!input.hasNextInt())
{
System.out.println("Invalid entry, please enter whole numbers.");
input.next();
}
buyNoteBooks = input.nextInt();
System.out.println("You bought " + buyNoteBooks + " notebooks." + " " + "SubTotal: $" + fm.format(total.subTotal(buyNoteBooks, buyInventory.noteBooks)));
finalPrice += total.subTotal(buyNoteBooks, buyInventory.noteBooks);
completeOrder = 0;
System.out.println("\n");
System.out.print("How many Calculators: ");
while (!input.hasNextInt())
{
System.out.println("Invalid entry, please enter whole numbers.");
input.next();
}
buyCalulators = input.nextInt();
System.out.println("You bought " + buyCalulators + " calculators." + " " + "SubTotal: $" + fm.format(total.subTotal(buyCalulators, buyInventory.calculators)));
finalPrice += total.subTotal(buyCalulators, buyInventory.calculators);
completeOrder = 0;
System.out.println("\n");
System.out.print("How many BackPacks: ");
while (!input.hasNextInt())
{
System.out.println("Invalid entry, please enter whole numbers.");
input.next();
}
buyBackPacks = input.nextInt();
System.out.println("You bought " + buyBackPacks + " backpacks."+ " " + "SubTotal: $" + fm.format(total.subTotal(buyBackPacks, buyInventory.backPacks)) );
finalPrice += total.subTotal(buyBackPacks, buyInventory.backPacks);
completeOrder = 0;
System.out.println("\n");
System.out.print("How many BlackPens: ");
while (!input.hasNextInt())
{
System.out.println("Invalid entry, please enter whole numbers.");
input.next();
}
buyBlackpens = input.nextInt();
System.out.println("You bought " + buyBlackpens + " blackpens." + " " + "SubTotal: $" + fm.format(total.subTotal(buyBlackpens, buyInventory.backPacks)));
finalPrice += total.subTotal(buyBlackpens, buyInventory.backPacks);
completeOrder = 0;
System.out.println("\n");
System.out.print("How many Pencils: ");
while (!input.hasNextInt())
{
System.out.println("Invalid entry, please enter whole numbers.");
input.next();
}
buyPencils = input.nextInt();
System.out.println("You bought " + buyPencils + " pencils." + " " + "SubTotal: $" + fm.format(total.subTotal(buyPencils, buyInventory.pencils)));
finalPrice += total.subTotal(buyPencils, buyInventory.pencils);
completeOrder = 100;
System.out.println("\n");
if (completeOrder == 100)
{
String linedivider = "_";
int divider = 1;
int dividerCount = 25;
while (divider < dividerCount)
{
System.out.print(linedivider + " ");
divider++;
if (divider == dividerCount)
{
break;
}
}
System.out.print("\n");
String totals = "GRAND TOTAL: $" + fm.format(finalPrice);
String grandTotal = String.format("%33s", totals);
System.out.println(" " + grandTotal + " ");
System.out.print("\n");
String linedivider2 = "_";
int divider2 = 1;
int dividerCount2 = 25;
while (divider2 < dividerCount2) {
System.out.print(linedivider2 + " ");
divider2++;
if (divider2 == dividerCount2)
{
break;
}
}
System.out.print("\n");
LocalDateTime purchaseDate = LocalDateTime.now();
DateTimeFormatter formattedTime = DateTimeFormatter.ofPattern("MM-dd-yyyy HH:mm:ss");
String newTimeFormat = purchaseDate.format(formattedTime);
String thanks = "THANK YOU FOR YOU ORDER!";
String time = String.format("%32s", newTimeFormat);
String thankYou = String.format("%35s", thanks);
System.out.println(" " + time + " ");
System.out.println(" " + thankYou + " ");
input.close();
}
}
}