diff --git a/TwoLiterStack/.classpath b/TwoLiterStack/.classpath
new file mode 100644
index 0000000..d171cd4
--- /dev/null
+++ b/TwoLiterStack/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/TwoLiterStack/src/main/Main.java b/TwoLiterStack/src/main/Main.java
index b5e47e3..a0b90d4 100644
--- a/TwoLiterStack/src/main/Main.java
+++ b/TwoLiterStack/src/main/Main.java
@@ -7,6 +7,8 @@
import java.text.DecimalFormat;
import java.util.Stack;
+import main.TwoLiter;
+
public class Main {
public static void main(String[] args) {
@@ -28,13 +30,16 @@ public static void main(String[] args) {
// ToDo Print the total price to exactly two decimal places.
// ToDo in the comments here, explain why this number changes each time you run the program.
+ // The number changes because there is a random number of soda's being put in
DecimalFormat df2 = new DecimalFormat("#.##");
System.out.println("Total Price is $" + df2.format(totalPrice));
// ToDo Compute the number of Dr. Pepper 2-liters in the stack
int totalDrPepper = 0;
for (TwoLiter twoLiter : twoLiterStack) {
- if (twoLiter.getFlavor().equals("Dr. Pepper")) {totalDrPepper++;}
+ if (twoLiter.getFlavor().equals("Cherry Coke")) {
+ totalDrPepper++;
+ }
}
System.out.println("Total Dr. Pepper = " + totalDrPepper);
}
diff --git a/TwoLiterStack/src/main/TwoLiter.java b/TwoLiterStack/src/main/TwoLiter.java
index 9a6d0d0..c706a9d 100644
--- a/TwoLiterStack/src/main/TwoLiter.java
+++ b/TwoLiterStack/src/main/TwoLiter.java
@@ -47,8 +47,8 @@ public static void add(Stack twoLiterStack, int count ) {
// Random r = new Random(42);
Random r = new Random();
for (int i = 0; i < count; i++) {
- twoLiterStack.add(new TwoLiter(UPCs[r.nextInt(UPCs.length - 1)],
- flavors[r.nextInt(flavors.length - 1)],
+ twoLiterStack.add(new TwoLiter(UPCs[r.nextInt(UPCs.length)],
+ flavors[r.nextInt(flavors.length)],
1.00 + r.nextFloat()));
}
}