From 0e6a4134f04649389a679e205284ffdf48366777 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 21:26:59 +0000 Subject: [PATCH 01/16] add deadline --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9c12bdd..2362803 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/6tlCTWq0) # 🧾 Mystery Receipt Generator (Java CLI Project) ## Overview From a403f55ede2de57ad533352fb01945f63b47683a Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Thu, 5 Feb 2026 16:59:55 -0500 Subject: [PATCH 02/16] Set up project structure --- .DS_Store | Bin 6148 -> 6148 bytes .idea/java-receipt-generator.iml | 4 +++- .idea/misc.xml | 2 +- .../codedifferently/MysteryReceiptGenerator | 1 + src/main/java/org/codedifferently/Main.java | 18 ++++++++++-------- .../codedifferently/MysteryReceiptGenerator | 1 + 6 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 out/production/java-receipt-generator/main/java/org/codedifferently/MysteryReceiptGenerator create mode 100644 src/main/java/org/codedifferently/MysteryReceiptGenerator diff --git a/.DS_Store b/.DS_Store index a70ee6b3e54c1471cfc4e0c3a1779f6f955424d5..d6f6f331dd3df2b7c348f47612ec48c4d996448f 100644 GIT binary patch delta 48 zcmZoMXfc@JFUrcmz`)4BAi%&-!H~<49Ze(7`s1A}~X2@qKWhn8?K}Z5c9f4Ty TKNv7DZ02FQ%DS1I<1aq|=U^3N diff --git a/.idea/java-receipt-generator.iml b/.idea/java-receipt-generator.iml index d6ebd48..f76df2b 100644 --- a/.idea/java-receipt-generator.iml +++ b/.idea/java-receipt-generator.iml @@ -2,7 +2,9 @@ - + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index b28c0fb..abbf8df 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/out/production/java-receipt-generator/main/java/org/codedifferently/MysteryReceiptGenerator b/out/production/java-receipt-generator/main/java/org/codedifferently/MysteryReceiptGenerator new file mode 100644 index 0000000..017d7d3 --- /dev/null +++ b/out/production/java-receipt-generator/main/java/org/codedifferently/MysteryReceiptGenerator @@ -0,0 +1 @@ +import java.util.*; diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 8a571aa..4715bd5 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -1,17 +1,19 @@ package org.codedifferently; +import java.util.*; //TIP To Run code, press or // click the icon in the gutter. public class Main { static void main() { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - IO.println(String.format("Hello and welcome!")); + Scanner sc = new Scanner(System.in); - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - IO.println("i = " + i); - } + System.out.print("Enter a name: "); + String name = sc.nextLine(); + + System.out.print("Enter your budget: "); + double budget = sc.nextDouble(); + + System.out.print("Enter a coupon code: "); + String coupon = sc.nextLine(); } } diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator b/src/main/java/org/codedifferently/MysteryReceiptGenerator new file mode 100644 index 0000000..017d7d3 --- /dev/null +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator @@ -0,0 +1 @@ +import java.util.*; From 799380220242510bb425c624de2729589db5d223 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Fri, 6 Feb 2026 19:09:41 -0500 Subject: [PATCH 03/16] Finished random generation methods --- src/main/java/org/codedifferently/MysteryReceiptGenerator | 1 - .../java/org/codedifferently/MysteryReceiptGenerator.java | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) delete mode 100644 src/main/java/org/codedifferently/MysteryReceiptGenerator create mode 100644 src/main/java/org/codedifferently/MysteryReceiptGenerator.java diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator b/src/main/java/org/codedifferently/MysteryReceiptGenerator deleted file mode 100644 index 017d7d3..0000000 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator +++ /dev/null @@ -1 +0,0 @@ -import java.util.*; diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java new file mode 100644 index 0000000..dc2b70c --- /dev/null +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -0,0 +1,5 @@ +import java.util.*; + +class MysteryReceiptGenerator() { + +} \ No newline at end of file From f20dca0669d5e9c5a5d44f5a0a12f59b7cba93cb Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Fri, 6 Feb 2026 19:25:58 -0500 Subject: [PATCH 04/16] Finished generateReceiptCode method --- .idea/encodings.xml | 2 + .idea/misc.xml | 1 + .idea/modules.xml | 8 ---- src/main/java/org/codedifferently/Main.java | 6 ++- .../MysteryReceiptGenerator.java | 44 ++++++++++++++++++- 5 files changed, 51 insertions(+), 10 deletions(-) delete mode 100644 .idea/modules.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml index e7cd972..b2320b5 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,6 +1,8 @@ + + diff --git a/.idea/misc.xml b/.idea/misc.xml index abbf8df..f2d5b8c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,6 +5,7 @@ diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 36361c6..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 4715bd5..f4d24f3 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -7,13 +7,17 @@ public class Main { static void main() { Scanner sc = new Scanner(System.in); - System.out.print("Enter a name: "); + System.out.print("Enter your name: "); String name = sc.nextLine(); System.out.print("Enter your budget: "); double budget = sc.nextDouble(); + sc.nextLine(); System.out.print("Enter a coupon code: "); String coupon = sc.nextLine(); + + sc.close(); + MysteryReceiptGenerator.printReceipt(name, budget, coupon); } } diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index dc2b70c..2200270 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -1,5 +1,47 @@ +package org.codedifferently; import java.util.*; -class MysteryReceiptGenerator() { +class MysteryReceiptGenerator { + String name = "Jayden's Emporium"; + public String validateCoupon(String coupon) { + return ""; + } + + public static String generateReceiptCode(String name, int visitorID) { + return (name.substring(0, 3)).toUpperCase() + "-" + visitorID; + } + + public static int generateVisitorID(Random random) { + return random.nextInt(1000, 1000000); + } + + public static double generatePrice(Random random) { + return ((double) random.nextInt(1000, 20000) / 100); + } + + public static double generateTax(Random random) { + return ((double) random.nextInt(2, 8) / 100); + } + + public double calculateTotal() { + return 0.0; + } + + public static void printReceipt(String name, double amount, String coupon) { + /* + Store name + Visitor ID + Receipt Code + Item Prices + Subtotal + Tax + Discounts + Final Total + */ + Random random = new Random(); + int visitorID = MysteryReceiptGenerator.generateVisitorID(random); + String receiptCode = MysteryReceiptGenerator.generateReceiptCode(name, visitorID); + System.out.println(receiptCode); + } } \ No newline at end of file From bb7ff9211b02097d6dab538f4dc93c453a146c74 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Fri, 6 Feb 2026 20:03:16 -0500 Subject: [PATCH 05/16] Wrote validate coupon and part of receipt --- .../MysteryReceiptGenerator.java | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index 2200270..5a8d04d 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -2,10 +2,19 @@ import java.util.*; class MysteryReceiptGenerator { - String name = "Jayden's Emporium"; + static String name = "Jayden's Emporium"; - public String validateCoupon(String coupon) { - return ""; + public static double validateCoupon(String coupon) { + if ((coupon).equalsIgnoreCase("friend")) { + System.out.println("-Coupon code " + "\"" + coupon + "\" accepted-"); + return 0.15; + } else if ((coupon).equalsIgnoreCase("employee")) { + System.out.println("-Coupon code " + "\"" + coupon + "\" accepted-"); + return 0.30; + } else { + System.out.println("-Coupon code not found.-"); + return 0.0; + } } public static String generateReceiptCode(String name, int visitorID) { @@ -21,14 +30,14 @@ public static double generatePrice(Random random) { } public static double generateTax(Random random) { - return ((double) random.nextInt(2, 8) / 100); + return (Math.round(random.nextDouble(0.01, 0.07))); } - public double calculateTotal() { - return 0.0; + public static double calculateSubtotal(double price1, double price2, double price3) { + return price1 + price2 + price3; } - public static void printReceipt(String name, double amount, String coupon) { + public static void printReceipt(String name, double budget, String coupon) { /* Store name Visitor ID @@ -42,6 +51,25 @@ public static void printReceipt(String name, double amount, String coupon) { Random random = new Random(); int visitorID = MysteryReceiptGenerator.generateVisitorID(random); String receiptCode = MysteryReceiptGenerator.generateReceiptCode(name, visitorID); - System.out.println(receiptCode); + double price1 = MysteryReceiptGenerator.generatePrice(random); + double price2 = MysteryReceiptGenerator.generatePrice(random); + double price3 = MysteryReceiptGenerator.generatePrice(random); + double tax = MysteryReceiptGenerator.generateTax(random); + double subtotal = MysteryReceiptGenerator.calculateSubtotal(price1, price2, price3); + double discount = MysteryReceiptGenerator.validateCoupon(coupon); + + // Prints the receipt to the console + System.out.println("\n" +MysteryReceiptGenerator.name); + System.out.println("----------------------------------------------------------------"); + System.out.println("ID Code: " + visitorID); + System.out.println("Receipt Code: " + receiptCode); + System.out.println("Item 1: $" + price1); + System.out.println("Item 2: $" + price2); + System.out.println("Item 3: $" + price3); + System.out.println("Subtotal: $" + subtotal); + System.out.println("\n-Price Adjustments-"); + System.out.println("Sales tax: " + (tax * 100) + "%"); + + } } \ No newline at end of file From 2a4535dd871ec4b2d61e3844cded6c6608991937 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 11:11:59 -0500 Subject: [PATCH 06/16] Debugged calculator methods and finished most of the reciept method --- .../MysteryReceiptGenerator.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index 5a8d04d..3735bf4 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -30,13 +30,19 @@ public static double generatePrice(Random random) { } public static double generateTax(Random random) { - return (Math.round(random.nextDouble(0.01, 0.07))); + return ((Math.floor(random.nextDouble(2, 7))) / 100); } public static double calculateSubtotal(double price1, double price2, double price3) { return price1 + price2 + price3; } + public static double calculateFinalTotal(double subtotal, double tax, double discount) { + double finalTotal = Math.ceil((subtotal + (subtotal * tax)) * 100) / 100; + finalTotal = Math.ceil((finalTotal - (finalTotal * discount)) * 100) / 100; + return finalTotal; + } + public static void printReceipt(String name, double budget, String coupon) { /* Store name @@ -56,7 +62,7 @@ public static void printReceipt(String name, double budget, String coupon) { double price3 = MysteryReceiptGenerator.generatePrice(random); double tax = MysteryReceiptGenerator.generateTax(random); double subtotal = MysteryReceiptGenerator.calculateSubtotal(price1, price2, price3); - double discount = MysteryReceiptGenerator.validateCoupon(coupon); + // Prints the receipt to the console System.out.println("\n" +MysteryReceiptGenerator.name); @@ -68,8 +74,12 @@ public static void printReceipt(String name, double budget, String coupon) { System.out.println("Item 3: $" + price3); System.out.println("Subtotal: $" + subtotal); System.out.println("\n-Price Adjustments-"); - System.out.println("Sales tax: " + (tax * 100) + "%"); - + System.out.println("Sales tax: " + ((int)(tax * 100)) + "%"); + double discount = MysteryReceiptGenerator.validateCoupon(coupon); + if (discount != 0.0) { + System.out.println("Discount: " + (int)(discount * 100) + "%"); + } + System.out.println("Final Total: $" + MysteryReceiptGenerator.calculateFinalTotal(subtotal, tax, discount)); } } \ No newline at end of file From a11f3d6f980517d7300db7f5640574562fcfde62 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 12:21:08 -0500 Subject: [PATCH 07/16] Fixed decimal formatting and some calculations. --- .../MysteryReceiptGenerator.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index 3735bf4..d77e7e3 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -5,14 +5,15 @@ class MysteryReceiptGenerator { static String name = "Jayden's Emporium"; public static double validateCoupon(String coupon) { + System.out.println("\nChecking for coupon code..."); if ((coupon).equalsIgnoreCase("friend")) { - System.out.println("-Coupon code " + "\"" + coupon + "\" accepted-"); + System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); return 0.15; } else if ((coupon).equalsIgnoreCase("employee")) { - System.out.println("-Coupon code " + "\"" + coupon + "\" accepted-"); + System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); return 0.30; } else { - System.out.println("-Coupon code not found.-"); + System.out.println("Coupon code " + "\"" + coupon + "\" not found!"); return 0.0; } } @@ -64,22 +65,31 @@ public static void printReceipt(String name, double budget, String coupon) { double subtotal = MysteryReceiptGenerator.calculateSubtotal(price1, price2, price3); + // Prints the receipt to the console System.out.println("\n" +MysteryReceiptGenerator.name); System.out.println("----------------------------------------------------------------"); System.out.println("ID Code: " + visitorID); System.out.println("Receipt Code: " + receiptCode); - System.out.println("Item 1: $" + price1); - System.out.println("Item 2: $" + price2); - System.out.println("Item 3: $" + price3); - System.out.println("Subtotal: $" + subtotal); - System.out.println("\n-Price Adjustments-"); + System.out.printf("Item 1: $%.2f%n", price1); + System.out.printf("Item 2: $%.2f%n", price2); + System.out.printf("Item 3: $%.2f%n", price3); + System.out.printf("Subtotal: $%.2f%n", subtotal); + System.out.println("\n---Price Adjustments---"); System.out.println("Sales tax: " + ((int)(tax * 100)) + "%"); double discount = MysteryReceiptGenerator.validateCoupon(coupon); + double finalTotal = MysteryReceiptGenerator.calculateFinalTotal(subtotal, tax, discount); if (discount != 0.0) { System.out.println("Discount: " + (int)(discount * 100) + "%"); } - System.out.println("Final Total: $" + MysteryReceiptGenerator.calculateFinalTotal(subtotal, tax, discount)); + System.out.printf("\nFinal Total: $%.2f%n", finalTotal); + + if (finalTotal > budget) { + System.out.printf("\nTransaction failed!\nInsufficient Funds. User is short by $%.2f dollars...\nCancelling transaction.", Math.abs(budget - finalTotal)); + } else { + + System.out.println("\nTransaction succeeded!\nThank you for shopping at Jayden's Emporium!"); + } } } \ No newline at end of file From 04c3f33fbb219b2d7f4c10f50d2c1b1cf71c2e49 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 13:16:36 -0500 Subject: [PATCH 08/16] Implemented chance time. --- .../MysteryReceiptGenerator.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index d77e7e3..8172422 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -4,7 +4,7 @@ class MysteryReceiptGenerator { static String name = "Jayden's Emporium"; - public static double validateCoupon(String coupon) { + public static double validateCoupon(String coupon, Random random) { System.out.println("\nChecking for coupon code..."); if ((coupon).equalsIgnoreCase("friend")) { System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); @@ -12,6 +12,17 @@ public static double validateCoupon(String coupon) { } else if ((coupon).equalsIgnoreCase("employee")) { System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); return 0.30; + } else if (coupon.equalsIgnoreCase("chance")) { + System.out.println("Coupon code " + "\"" + coupon + "\" accepted!\nWelcome to Chance Time!\nRolling the dice (1-6)..."); + int diceRoll = (random.nextInt(1, 7)); + System.out.println("Rolled " + diceRoll + "."); + if (diceRoll % 2 == 0) { + System.out.println("YOU'VE GOTTEN LUCKY!!!"); + return 0.40; + } else { + System.out.println("Better luck next time..."); + return -0.05; + } } else { System.out.println("Coupon code " + "\"" + coupon + "\" not found!"); return 0.0; @@ -31,7 +42,7 @@ public static double generatePrice(Random random) { } public static double generateTax(Random random) { - return ((Math.floor(random.nextDouble(2, 7))) / 100); + return ((double) (Math.round(random.nextDouble(1.5, 7.5))) / 100); } public static double calculateSubtotal(double price1, double price2, double price3) { @@ -77,7 +88,7 @@ public static void printReceipt(String name, double budget, String coupon) { System.out.printf("Subtotal: $%.2f%n", subtotal); System.out.println("\n---Price Adjustments---"); System.out.println("Sales tax: " + ((int)(tax * 100)) + "%"); - double discount = MysteryReceiptGenerator.validateCoupon(coupon); + double discount = MysteryReceiptGenerator.validateCoupon(coupon, random); double finalTotal = MysteryReceiptGenerator.calculateFinalTotal(subtotal, tax, discount); if (discount != 0.0) { System.out.println("Discount: " + (int)(discount * 100) + "%"); @@ -87,9 +98,7 @@ public static void printReceipt(String name, double budget, String coupon) { if (finalTotal > budget) { System.out.printf("\nTransaction failed!\nInsufficient Funds. User is short by $%.2f dollars...\nCancelling transaction.", Math.abs(budget - finalTotal)); } else { - System.out.println("\nTransaction succeeded!\nThank you for shopping at Jayden's Emporium!"); } - } } \ No newline at end of file From 9f098d6d0dc6301f9f0a2e0d2fab863275a14379 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 13:19:00 -0500 Subject: [PATCH 09/16] Implemented Calculator class --- src/main/java/org/codedifferently/Calculator.java | 13 +++++++++++++ .../codedifferently/MysteryReceiptGenerator.java | 14 ++------------ 2 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 src/main/java/org/codedifferently/Calculator.java diff --git a/src/main/java/org/codedifferently/Calculator.java b/src/main/java/org/codedifferently/Calculator.java new file mode 100644 index 0000000..5c05dcf --- /dev/null +++ b/src/main/java/org/codedifferently/Calculator.java @@ -0,0 +1,13 @@ +package org.codedifferently; + +public class Calculator { + public static double calculateSubtotal(double price1, double price2, double price3) { + return price1 + price2 + price3; + } + + public static double calculateFinalTotal(double subtotal, double tax, double discount) { + double finalTotal = Math.ceil((subtotal + (subtotal * tax)) * 100) / 100; + finalTotal = Math.ceil((finalTotal - (finalTotal * discount)) * 100) / 100; + return finalTotal; + } +} diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index 8172422..9185abd 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -45,16 +45,6 @@ public static double generateTax(Random random) { return ((double) (Math.round(random.nextDouble(1.5, 7.5))) / 100); } - public static double calculateSubtotal(double price1, double price2, double price3) { - return price1 + price2 + price3; - } - - public static double calculateFinalTotal(double subtotal, double tax, double discount) { - double finalTotal = Math.ceil((subtotal + (subtotal * tax)) * 100) / 100; - finalTotal = Math.ceil((finalTotal - (finalTotal * discount)) * 100) / 100; - return finalTotal; - } - public static void printReceipt(String name, double budget, String coupon) { /* Store name @@ -73,7 +63,7 @@ public static void printReceipt(String name, double budget, String coupon) { double price2 = MysteryReceiptGenerator.generatePrice(random); double price3 = MysteryReceiptGenerator.generatePrice(random); double tax = MysteryReceiptGenerator.generateTax(random); - double subtotal = MysteryReceiptGenerator.calculateSubtotal(price1, price2, price3); + double subtotal = Calculator.calculateSubtotal(price1, price2, price3); @@ -89,7 +79,7 @@ public static void printReceipt(String name, double budget, String coupon) { System.out.println("\n---Price Adjustments---"); System.out.println("Sales tax: " + ((int)(tax * 100)) + "%"); double discount = MysteryReceiptGenerator.validateCoupon(coupon, random); - double finalTotal = MysteryReceiptGenerator.calculateFinalTotal(subtotal, tax, discount); + double finalTotal = Calculator.calculateFinalTotal(subtotal, tax, discount); if (discount != 0.0) { System.out.println("Discount: " + (int)(discount * 100) + "%"); } From aec1f38abfb39a2a672463fead0bc704204ebe9d Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 13:47:43 -0500 Subject: [PATCH 10/16] Implemented RandomDataGenerator class. --- .../MysteryReceiptGenerator.java | 31 +++++-------------- .../codedifferently/RandomDataGenerator.java | 20 ++++++++++++ ...Calculator.java => ReceiptCalculator.java} | 2 +- 3 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 src/main/java/org/codedifferently/RandomDataGenerator.java rename src/main/java/org/codedifferently/{Calculator.java => ReceiptCalculator.java} (93%) diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index 9185abd..58503cc 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -29,21 +29,6 @@ public static double validateCoupon(String coupon, Random random) { } } - public static String generateReceiptCode(String name, int visitorID) { - return (name.substring(0, 3)).toUpperCase() + "-" + visitorID; - } - - public static int generateVisitorID(Random random) { - return random.nextInt(1000, 1000000); - } - - public static double generatePrice(Random random) { - return ((double) random.nextInt(1000, 20000) / 100); - } - - public static double generateTax(Random random) { - return ((double) (Math.round(random.nextDouble(1.5, 7.5))) / 100); - } public static void printReceipt(String name, double budget, String coupon) { /* @@ -57,13 +42,13 @@ public static void printReceipt(String name, double budget, String coupon) { Final Total */ Random random = new Random(); - int visitorID = MysteryReceiptGenerator.generateVisitorID(random); - String receiptCode = MysteryReceiptGenerator.generateReceiptCode(name, visitorID); - double price1 = MysteryReceiptGenerator.generatePrice(random); - double price2 = MysteryReceiptGenerator.generatePrice(random); - double price3 = MysteryReceiptGenerator.generatePrice(random); - double tax = MysteryReceiptGenerator.generateTax(random); - double subtotal = Calculator.calculateSubtotal(price1, price2, price3); + int visitorID = RandomDataGenerator.generateVisitorID(random); + String receiptCode = RandomDataGenerator.generateReceiptCode(name, visitorID); + double price1 = RandomDataGenerator.generatePrice(random); + double price2 = RandomDataGenerator.generatePrice(random); + double price3 = RandomDataGenerator.generatePrice(random); + double tax = RandomDataGenerator.generateTax(random); + double subtotal = ReceiptCalculator.calculateSubtotal(price1, price2, price3); @@ -79,7 +64,7 @@ public static void printReceipt(String name, double budget, String coupon) { System.out.println("\n---Price Adjustments---"); System.out.println("Sales tax: " + ((int)(tax * 100)) + "%"); double discount = MysteryReceiptGenerator.validateCoupon(coupon, random); - double finalTotal = Calculator.calculateFinalTotal(subtotal, tax, discount); + double finalTotal = ReceiptCalculator.calculateFinalTotal(subtotal, tax, discount); if (discount != 0.0) { System.out.println("Discount: " + (int)(discount * 100) + "%"); } diff --git a/src/main/java/org/codedifferently/RandomDataGenerator.java b/src/main/java/org/codedifferently/RandomDataGenerator.java new file mode 100644 index 0000000..131c871 --- /dev/null +++ b/src/main/java/org/codedifferently/RandomDataGenerator.java @@ -0,0 +1,20 @@ +package org.codedifferently; +import java.util.Random; + +public class RandomDataGenerator { + public static String generateReceiptCode(String name, int visitorID) { + return (name.substring(0, 3)).toUpperCase() + "-" + visitorID; + } + + public static int generateVisitorID(Random random) { + return random.nextInt(1000, 1000000); + } + + public static double generatePrice(Random random) { + return ((double) random.nextInt(1000, 20000) / 100); + } + + public static double generateTax(Random random) { + return ((double) (Math.round(random.nextDouble(1.5, 7.5))) / 100); + } +} diff --git a/src/main/java/org/codedifferently/Calculator.java b/src/main/java/org/codedifferently/ReceiptCalculator.java similarity index 93% rename from src/main/java/org/codedifferently/Calculator.java rename to src/main/java/org/codedifferently/ReceiptCalculator.java index 5c05dcf..5cbbd24 100644 --- a/src/main/java/org/codedifferently/Calculator.java +++ b/src/main/java/org/codedifferently/ReceiptCalculator.java @@ -1,6 +1,6 @@ package org.codedifferently; -public class Calculator { +public class ReceiptCalculator { public static double calculateSubtotal(double price1, double price2, double price3) { return price1 + price2 + price3; } From d626b4c13708e3d13cf71b55ad2e272f13bde3e8 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 13:53:06 -0500 Subject: [PATCH 11/16] Implemented CouponValidator class. --- src/main/java/org/codedifferently/CouponValidator.java | 4 ++++ .../{ReceiptCalculator.java => MysteryReceiptCalculator.java} | 0 2 files changed, 4 insertions(+) create mode 100644 src/main/java/org/codedifferently/CouponValidator.java rename src/main/java/org/codedifferently/{ReceiptCalculator.java => MysteryReceiptCalculator.java} (100%) diff --git a/src/main/java/org/codedifferently/CouponValidator.java b/src/main/java/org/codedifferently/CouponValidator.java new file mode 100644 index 0000000..c5e9ca5 --- /dev/null +++ b/src/main/java/org/codedifferently/CouponValidator.java @@ -0,0 +1,4 @@ +package org.codedifferently; + +public class CouponValidator { +} diff --git a/src/main/java/org/codedifferently/ReceiptCalculator.java b/src/main/java/org/codedifferently/MysteryReceiptCalculator.java similarity index 100% rename from src/main/java/org/codedifferently/ReceiptCalculator.java rename to src/main/java/org/codedifferently/MysteryReceiptCalculator.java From 2958096c8519c202ed426271d6973585b77cf15f Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 13:53:26 -0500 Subject: [PATCH 12/16] Implemented CouponValidator class. --- .../org/codedifferently/CouponValidator.java | 26 ++++++++++++++ .../MysteryReceiptCalculator.java | 2 +- .../MysteryReceiptGenerator.java | 36 +++---------------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/codedifferently/CouponValidator.java b/src/main/java/org/codedifferently/CouponValidator.java index c5e9ca5..f222210 100644 --- a/src/main/java/org/codedifferently/CouponValidator.java +++ b/src/main/java/org/codedifferently/CouponValidator.java @@ -1,4 +1,30 @@ package org.codedifferently; +import java.util.Random; + public class CouponValidator { + public static double validateCoupon(String coupon, Random random) { + System.out.println("\nChecking for coupon code..."); + if ((coupon).equalsIgnoreCase("friend")) { + System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); + return 0.15; + } else if ((coupon).equalsIgnoreCase("employee")) { + System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); + return 0.30; + } else if (coupon.equalsIgnoreCase("chance")) { + System.out.println("Coupon code " + "\"" + coupon + "\" accepted!\nWelcome to Chance Time!\nRolling the dice (1-6)..."); + int diceRoll = (random.nextInt(1, 7)); + System.out.println("Rolled " + diceRoll + "."); + if (diceRoll % 2 == 0) { + System.out.println("YOU'VE GOTTEN LUCKY!!!"); + return 0.40; + } else { + System.out.println("Better luck next time..."); + return -0.05; + } + } else { + System.out.println("Coupon code " + "\"" + coupon + "\" not found!"); + return 0.0; + } + } } diff --git a/src/main/java/org/codedifferently/MysteryReceiptCalculator.java b/src/main/java/org/codedifferently/MysteryReceiptCalculator.java index 5cbbd24..9e64af1 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptCalculator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptCalculator.java @@ -1,6 +1,6 @@ package org.codedifferently; -public class ReceiptCalculator { +public class MysteryReceiptCalculator { public static double calculateSubtotal(double price1, double price2, double price3) { return price1 + price2 + price3; } diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java index 58503cc..e96497d 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptGenerator.java @@ -2,33 +2,7 @@ import java.util.*; class MysteryReceiptGenerator { - static String name = "Jayden's Emporium"; - - public static double validateCoupon(String coupon, Random random) { - System.out.println("\nChecking for coupon code..."); - if ((coupon).equalsIgnoreCase("friend")) { - System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); - return 0.15; - } else if ((coupon).equalsIgnoreCase("employee")) { - System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); - return 0.30; - } else if (coupon.equalsIgnoreCase("chance")) { - System.out.println("Coupon code " + "\"" + coupon + "\" accepted!\nWelcome to Chance Time!\nRolling the dice (1-6)..."); - int diceRoll = (random.nextInt(1, 7)); - System.out.println("Rolled " + diceRoll + "."); - if (diceRoll % 2 == 0) { - System.out.println("YOU'VE GOTTEN LUCKY!!!"); - return 0.40; - } else { - System.out.println("Better luck next time..."); - return -0.05; - } - } else { - System.out.println("Coupon code " + "\"" + coupon + "\" not found!"); - return 0.0; - } - } - + static String storeName = "Jayden's Emporium"; public static void printReceipt(String name, double budget, String coupon) { /* @@ -48,12 +22,12 @@ public static void printReceipt(String name, double budget, String coupon) { double price2 = RandomDataGenerator.generatePrice(random); double price3 = RandomDataGenerator.generatePrice(random); double tax = RandomDataGenerator.generateTax(random); - double subtotal = ReceiptCalculator.calculateSubtotal(price1, price2, price3); + double subtotal = MysteryReceiptCalculator.calculateSubtotal(price1, price2, price3); // Prints the receipt to the console - System.out.println("\n" +MysteryReceiptGenerator.name); + System.out.println("\n" +MysteryReceiptGenerator.storeName); System.out.println("----------------------------------------------------------------"); System.out.println("ID Code: " + visitorID); System.out.println("Receipt Code: " + receiptCode); @@ -63,8 +37,8 @@ public static void printReceipt(String name, double budget, String coupon) { System.out.printf("Subtotal: $%.2f%n", subtotal); System.out.println("\n---Price Adjustments---"); System.out.println("Sales tax: " + ((int)(tax * 100)) + "%"); - double discount = MysteryReceiptGenerator.validateCoupon(coupon, random); - double finalTotal = ReceiptCalculator.calculateFinalTotal(subtotal, tax, discount); + double discount = CouponValidator.validateCoupon(coupon, random); + double finalTotal = MysteryReceiptCalculator.calculateFinalTotal(subtotal, tax, discount); if (discount != 0.0) { System.out.println("Discount: " + (int)(discount * 100) + "%"); } From d068c90da08b01afeb943257e11681e18bf5224d Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 14:00:18 -0500 Subject: [PATCH 13/16] Fixed some string formatting errors. --- src/main/java/org/codedifferently/Main.java | 6 +++--- ...teryReceiptGenerator.java => MysteryReceiptPrinter.java} | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/org/codedifferently/{MysteryReceiptGenerator.java => MysteryReceiptPrinter.java} (95%) diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index f4d24f3..c31cb01 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -8,16 +8,16 @@ static void main() { Scanner sc = new Scanner(System.in); System.out.print("Enter your name: "); - String name = sc.nextLine(); + String name = sc.nextLine().trim(); System.out.print("Enter your budget: "); double budget = sc.nextDouble(); sc.nextLine(); System.out.print("Enter a coupon code: "); - String coupon = sc.nextLine(); + String coupon = sc.nextLine().trim(); sc.close(); - MysteryReceiptGenerator.printReceipt(name, budget, coupon); + MysteryReceiptPrinter.printReceipt(name, budget, coupon); } } diff --git a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java b/src/main/java/org/codedifferently/MysteryReceiptPrinter.java similarity index 95% rename from src/main/java/org/codedifferently/MysteryReceiptGenerator.java rename to src/main/java/org/codedifferently/MysteryReceiptPrinter.java index e96497d..0197fd3 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptGenerator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptPrinter.java @@ -1,7 +1,7 @@ package org.codedifferently; import java.util.*; -class MysteryReceiptGenerator { +class MysteryReceiptPrinter { static String storeName = "Jayden's Emporium"; public static void printReceipt(String name, double budget, String coupon) { @@ -27,7 +27,7 @@ public static void printReceipt(String name, double budget, String coupon) { // Prints the receipt to the console - System.out.println("\n" +MysteryReceiptGenerator.storeName); + System.out.println("\n" + MysteryReceiptPrinter.storeName); System.out.println("----------------------------------------------------------------"); System.out.println("ID Code: " + visitorID); System.out.println("Receipt Code: " + receiptCode); From 3dd445e0e3d43813b2bd56b4da3343e621d55c58 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Sat, 7 Feb 2026 15:23:51 -0500 Subject: [PATCH 14/16] Added comments. --- .../org/codedifferently/CouponValidator.java | 8 +++++ src/main/java/org/codedifferently/Main.java | 4 +++ .../MysteryReceiptCalculator.java | 2 ++ .../MysteryReceiptPrinter.java | 31 ++++++++++++------- .../codedifferently/RandomDataGenerator.java | 4 +++ 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/codedifferently/CouponValidator.java b/src/main/java/org/codedifferently/CouponValidator.java index f222210..72290e0 100644 --- a/src/main/java/org/codedifferently/CouponValidator.java +++ b/src/main/java/org/codedifferently/CouponValidator.java @@ -3,15 +3,22 @@ import java.util.Random; public class CouponValidator { + // Checks the coupon code to see if a discount should be applied. public static double validateCoupon(String coupon, Random random) { System.out.println("\nChecking for coupon code..."); if ((coupon).equalsIgnoreCase("friend")) { + // Applies a 15% discount if the "friend" coupon code is used. System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); return 0.15; } else if ((coupon).equalsIgnoreCase("employee")) { + // Applies a 30% discount if the coupon code "employee" is used. System.out.println("Coupon code " + "\"" + coupon + "\" accepted!"); return 0.30; } else if (coupon.equalsIgnoreCase("chance")) { + /* Starts "chance time" which will roll a die. If the result is even, + a 40% discount will be applied. If it is odd, all items will become 5% + more expensive. + */ System.out.println("Coupon code " + "\"" + coupon + "\" accepted!\nWelcome to Chance Time!\nRolling the dice (1-6)..."); int diceRoll = (random.nextInt(1, 7)); System.out.println("Rolled " + diceRoll + "."); @@ -23,6 +30,7 @@ public static double validateCoupon(String coupon, Random random) { return -0.05; } } else { + // The coupon code provided does not exist. The discount rate will be 0%. System.out.println("Coupon code " + "\"" + coupon + "\" not found!"); return 0.0; } diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index c31cb01..0bedb53 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -7,17 +7,21 @@ public class Main { static void main() { Scanner sc = new Scanner(System.in); + // Collects input for the user's name and stores it in a variable System.out.print("Enter your name: "); String name = sc.nextLine().trim(); + // Collects input for the user's budget and stores it in a variable System.out.print("Enter your budget: "); double budget = sc.nextDouble(); sc.nextLine(); + // Collects input for the user's coupon and stores it in a variable System.out.print("Enter a coupon code: "); String coupon = sc.nextLine().trim(); sc.close(); + // Prints the receipt out to the console. MysteryReceiptPrinter.printReceipt(name, budget, coupon); } } diff --git a/src/main/java/org/codedifferently/MysteryReceiptCalculator.java b/src/main/java/org/codedifferently/MysteryReceiptCalculator.java index 9e64af1..80d4a42 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptCalculator.java +++ b/src/main/java/org/codedifferently/MysteryReceiptCalculator.java @@ -1,10 +1,12 @@ package org.codedifferently; public class MysteryReceiptCalculator { + // Calculates the sum of the three prices given as arguments. public static double calculateSubtotal(double price1, double price2, double price3) { return price1 + price2 + price3; } + // Calculates the final price with the tax rate and discount rate applied. public static double calculateFinalTotal(double subtotal, double tax, double discount) { double finalTotal = Math.ceil((subtotal + (subtotal * tax)) * 100) / 100; finalTotal = Math.ceil((finalTotal - (finalTotal * discount)) * 100) / 100; diff --git a/src/main/java/org/codedifferently/MysteryReceiptPrinter.java b/src/main/java/org/codedifferently/MysteryReceiptPrinter.java index 0197fd3..83d90f8 100644 --- a/src/main/java/org/codedifferently/MysteryReceiptPrinter.java +++ b/src/main/java/org/codedifferently/MysteryReceiptPrinter.java @@ -4,27 +4,27 @@ class MysteryReceiptPrinter { static String storeName = "Jayden's Emporium"; + // Prints the receipt out to the console. public static void printReceipt(String name, double budget, String coupon) { - /* - Store name - Visitor ID - Receipt Code - Item Prices - Subtotal - Tax - Discounts - Final Total - */ + // Creates a random object that will be used for any random elements. Random random = new Random(); + + // Stores a random visitor ID in a variable. int visitorID = RandomDataGenerator.generateVisitorID(random); + + // Stores a random receipt code in a variable. String receiptCode = RandomDataGenerator.generateReceiptCode(name, visitorID); + + // Stores three random prices in three different variables. double price1 = RandomDataGenerator.generatePrice(random); double price2 = RandomDataGenerator.generatePrice(random); double price3 = RandomDataGenerator.generatePrice(random); - double tax = RandomDataGenerator.generateTax(random); - double subtotal = MysteryReceiptCalculator.calculateSubtotal(price1, price2, price3); + // Stores a random tax rate in a variable. + double tax = RandomDataGenerator.generateTax(random); + // Stores the subtotal in a variable. + double subtotal = MysteryReceiptCalculator.calculateSubtotal(price1, price2, price3); // Prints the receipt to the console System.out.println("\n" + MysteryReceiptPrinter.storeName); @@ -37,13 +37,20 @@ public static void printReceipt(String name, double budget, String coupon) { System.out.printf("Subtotal: $%.2f%n", subtotal); System.out.println("\n---Price Adjustments---"); System.out.println("Sales tax: " + ((int)(tax * 100)) + "%"); + + // Stores the discount rate in a variable. double discount = CouponValidator.validateCoupon(coupon, random); + + // Stores the final total in a variable. double finalTotal = MysteryReceiptCalculator.calculateFinalTotal(subtotal, tax, discount); + + // Prints the discount only if one exists. if (discount != 0.0) { System.out.println("Discount: " + (int)(discount * 100) + "%"); } System.out.printf("\nFinal Total: $%.2f%n", finalTotal); + // Checks to see if the user has enough money to complete the transaction. if (finalTotal > budget) { System.out.printf("\nTransaction failed!\nInsufficient Funds. User is short by $%.2f dollars...\nCancelling transaction.", Math.abs(budget - finalTotal)); } else { diff --git a/src/main/java/org/codedifferently/RandomDataGenerator.java b/src/main/java/org/codedifferently/RandomDataGenerator.java index 131c871..4934ebc 100644 --- a/src/main/java/org/codedifferently/RandomDataGenerator.java +++ b/src/main/java/org/codedifferently/RandomDataGenerator.java @@ -2,18 +2,22 @@ import java.util.Random; public class RandomDataGenerator { + // Generates a random receipt code for the user. public static String generateReceiptCode(String name, int visitorID) { return (name.substring(0, 3)).toUpperCase() + "-" + visitorID; } + // Generates a random visitor ID for the user. public static int generateVisitorID(Random random) { return random.nextInt(1000, 1000000); } + // Generates a random item price. public static double generatePrice(Random random) { return ((double) random.nextInt(1000, 20000) / 100); } + // Generates a random sales tax rate for the store. public static double generateTax(Random random) { return ((double) (Math.round(random.nextDouble(1.5, 7.5))) / 100); } From 4db2ef740cdf7b1ac739f1b44bba14fe2f0efbc6 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Mon, 9 Feb 2026 09:26:17 -0500 Subject: [PATCH 15/16] Started readme --- src/main/java/org/codedifferently/README.md | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/main/java/org/codedifferently/README.md diff --git a/src/main/java/org/codedifferently/README.md b/src/main/java/org/codedifferently/README.md new file mode 100644 index 0000000..8699d23 --- /dev/null +++ b/src/main/java/org/codedifferently/README.md @@ -0,0 +1,58 @@ +# 🧾 Mystery Receipt Generator + +## Overview + +A Java program that generates **Mystery receipt** based on user input and randomly generated values. + +Each time the program runs, the receipt is **slightly different**. + +--- + +## How it works + +User inputs their name, budget, and a discount code. A receipt is then generated containing: + + * The name of the store + * A receipt code + * 3 item prices + * Subtotal + * Price adjustments containing any price modifiers, such as tax and discount if applicable + * The final total + +## Sample output +Jayden's Emporium +---------------------------------------------------------------- +ID Code: 191591 +Receipt Code: JAY-191591 +Item 1: $72.65 +Item 2: $103.84 +Item 3: $121.23 +Subtotal: $297.72 + +---Price Adjustments--- +Sales tax: 6% + +Checking for coupon code... +Coupon code "employee" accepted! +Discount: 30% + +Final Total: $220.92 + +Transaction failed! +Insufficient Funds. User is short by $20.92 dollars... +Cancelling transaction. + +## Java Concepts Used +The following concepts are used in this project. + +* Use of Variables +* Creation of objects +* Organization of multiple classes and methods within them +* Collecting user input using `Scanner` +* Generating random values using the `Random` class +* The Math class and its functions +* Manipulating and validating text using the `String` class +* (`if / else`) Conditionals + + +---** \ No newline at end of file From a6b74af0dd73cc1987c0945162fe0eafd41c7821 Mon Sep 17 00:00:00 2001 From: Jayden Andrews Date: Mon, 9 Feb 2026 10:33:13 -0500 Subject: [PATCH 16/16] Cleaned up README. --- RECEIPTREADME.md | 66 +++++++++++++++++++++ src/main/java/org/codedifferently/README.md | 58 ------------------ 2 files changed, 66 insertions(+), 58 deletions(-) create mode 100644 RECEIPTREADME.md delete mode 100644 src/main/java/org/codedifferently/README.md diff --git a/RECEIPTREADME.md b/RECEIPTREADME.md new file mode 100644 index 0000000..6b5f90d --- /dev/null +++ b/RECEIPTREADME.md @@ -0,0 +1,66 @@ +# 🧾 Mystery Receipt Generator + +## Overview + +This Java program that generates **Mystery receipt** based on user input and randomly generated values. +It will then compare +the user's budget to the subtotal of the items on the receipt and inform the user of whether their transaction was **successful** or **not**. + +Each time the program runs, the receipt is **slightly different**. + +--- + +## How it works + +The program takes input for the user's: + * name + * budget + * A discount code. + +A receipt is then generated containing: + + * The name of the store + * A receipt code + * 3 item prices + * Subtotal + * Price adjustments containing any price modifiers, such as tax and discount if applicable + * The final total +--- +Sample Input & Output +---------------------------------------------------------------- +Name: Jayden +Budget: 200.00 +Discount: employee + +Jayden's Emporium +ID Code: 191591 +Receipt Code: JAY-191591 +Item 1: \$72.65 +Item 2: \$103.84 +Item 3: \$121.23 +Subtotal: \$297.72 + +---Price Adjustments--- +Sales tax: 6% + +Checking for coupon code... +Coupon code "employee" accepted! +Discount: 30% + +Final Total: $220.92 + +Transaction failed! +Insufficient Funds. User is short by $20.92 dollars... +Cancelling transaction. +--- +## Java Concepts Used +The following Java concepts are used in this project: + +* Use of Variables +* Creation of objects +* Organization of multiple classes and methods within them +* Collecting user input using `Scanner` +* Generating random values using the `Random` class +* The `Math` class and its functions +* Manipulating and validating text using the `String` class +* (`if / else`) Conditionals \ No newline at end of file diff --git a/src/main/java/org/codedifferently/README.md b/src/main/java/org/codedifferently/README.md deleted file mode 100644 index 8699d23..0000000 --- a/src/main/java/org/codedifferently/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# 🧾 Mystery Receipt Generator - -## Overview - -A Java program that generates **Mystery receipt** based on user input and randomly generated values. - -Each time the program runs, the receipt is **slightly different**. - ---- - -## How it works - -User inputs their name, budget, and a discount code. A receipt is then generated containing: - - * The name of the store - * A receipt code - * 3 item prices - * Subtotal - * Price adjustments containing any price modifiers, such as tax and discount if applicable - * The final total - -## Sample output -Jayden's Emporium ----------------------------------------------------------------- -ID Code: 191591 -Receipt Code: JAY-191591 -Item 1: $72.65 -Item 2: $103.84 -Item 3: $121.23 -Subtotal: $297.72 - ----Price Adjustments--- -Sales tax: 6% - -Checking for coupon code... -Coupon code "employee" accepted! -Discount: 30% - -Final Total: $220.92 - -Transaction failed! -Insufficient Funds. User is short by $20.92 dollars... -Cancelling transaction. - -## Java Concepts Used -The following concepts are used in this project. - -* Use of Variables -* Creation of objects -* Organization of multiple classes and methods within them -* Collecting user input using `Scanner` -* Generating random values using the `Random` class -* The Math class and its functions -* Manipulating and validating text using the `String` class -* (`if / else`) Conditionals - - ----** \ No newline at end of file