diff --git a/T3Q1-1/T3Q1-1.iml b/T3Q1-1/T3Q1-1.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q1-1/T3Q1-1.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/T3Q1-1/src/VendingMachine.java b/T3Q1-1/src/VendingMachine.java new file mode 100644 index 0000000..d7291db --- /dev/null +++ b/T3Q1-1/src/VendingMachine.java @@ -0,0 +1,78 @@ +import java.util.Scanner; + +public class VendingMachine { + + public VendingMachine() {} + + public double selectDrink() { + Scanner sc = new Scanner(System.in); + + int drinkSelection; + double drinkCost = 0; + + System.out.println("====== Vending Machine ======"); + System.out.println("|1. Buy Beer ($3.00) |"); + System.out.println("|2. Buy Coke ($1.00) |"); + System.out.println("|3. Buy Green Tea ($5.00) |"); + System.out.println("|============================"); + + do { + System.out.println("Please enter selection: "); + drinkSelection = sc.nextInt(); + } while (drinkSelection < 1 || drinkSelection > 3); + if (drinkSelection == 1) drinkCost = 3.00; + else if (drinkSelection == 2) drinkCost = 1.00; + else if (drinkSelection == 3) drinkCost = 5.00; + return drinkCost; + } + + public double insertCoins(double drinkCost) { + double amount = 0.0; + + Scanner sc = new Scanner(System.in); + System.out.println("Please insert coins: "); + System.out.println("========== Coins Input ==========="); + System.out.println("|Enter 'Q' for ten cents input |"); + System.out.println("|Enter 'T' for twenty cents input|"); + System.out.println("|Enter 'F' for fifty cents input |"); + System.out.println("|Enter 'N' for a dollar input |"); + System.out.println("=================================="); + + do { + char coin = sc.next().charAt(0); + switch (coin) + { + case 'Q': case 'q': + amount += 0.10; + break; + case 'T': case 't': + amount += 0.20; + break; + case 'F': case 'f': + amount += 0.50; + break; + case 'N': case 'n': + amount += 1.00; + break; + } + System.out.printf("Coins inserted: %.2f \n", amount); + } while (amount < drinkCost); + return amount; + } + + public void checkChange(double amount, double drinkCost) + { + double change = 0.0; + if (amount > drinkCost) + { + change = amount - drinkCost; + System.out.printf("Change $ %.2f \n", change); + } + } + + public void printReceipt() + { + System.out.println("Please collect your drink"); + System.out.println("Thank you!!"); + } +} \ No newline at end of file diff --git a/T3Q1-2/T3Q1-2.iml b/T3Q1-2/T3Q1-2.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q1-2/T3Q1-2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/T3Q1-3/T3Q1-3.iml b/T3Q1-3/T3Q1-3.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q1-3/T3Q1-3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/T3Q1-4/T3Q1-4.iml b/T3Q1-4/T3Q1-4.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q1-4/T3Q1-4.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/T3Q1-extra1/T3Q1-extra1.iml b/T3Q1-extra1/T3Q1-extra1.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q1-extra1/T3Q1-extra1.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/T3Q2-1/src/Point.java b/T3Q2-1/src/Point.java new file mode 100644 index 0000000..4cf799a --- /dev/null +++ b/T3Q2-1/src/Point.java @@ -0,0 +1,13 @@ +public class Point { + protected int x, y; + + public Point() { x = 0; y = 0; } + public Point(int x, int y) { this.x = x; this.y = y; } + + public void setPoint(int x, int y) { this.x = x; this.y = y; } + + public int getX() { return x; } + public int getY() { return y; } + + public String toString() { return "[" + x + "," + y + "]"; } +} \ No newline at end of file diff --git a/T3Q2-2/T3Q2-2.iml b/T3Q2-2/T3Q2-2.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q2-2/T3Q2-2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/T3Q2-3/T3Q2-3.iml b/T3Q2-3/T3Q2-3.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q2-3/T3Q2-3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/T3Q2-4/T3Q2-4.iml b/T3Q2-4/T3Q2-4.iml new file mode 100644 index 0000000..82236ea --- /dev/null +++ b/T3Q2-4/T3Q2-4.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file