From 80dea63d4a35dfa515e2c3640047afbd433b16bf 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:13:38 +0000 Subject: [PATCH 1/6] 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 4d198a8f8f546e076125c283125e82a9509cc012 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Sat, 7 Feb 2026 13:12:46 -0500 Subject: [PATCH 2/6] Set up project structure, Add receipt calculations, Format receipt output --- .DS_Store | Bin 6148 -> 6148 bytes .idea/encodings.xml | 2 + .idea/java-receipt-generator.iml | 4 +- .idea/misc.xml | 3 +- .idea/modules.xml | 8 -- .../org/codedifferently/CalculateTax.java | 87 ++++++++++++++++++ src/main/java/org/codedifferently/Main.java | 37 ++++++-- 7 files changed, 124 insertions(+), 17 deletions(-) delete mode 100644 .idea/modules.xml create mode 100644 src/main/java/org/codedifferently/CalculateTax.java 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/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/java-receipt-generator.iml b/.idea/java-receipt-generator.iml index d6ebd48..9d643a5 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..5b2ced4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,10 +5,11 @@ - + \ No newline at end of file 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/CalculateTax.java b/src/main/java/org/codedifferently/CalculateTax.java new file mode 100644 index 0000000..151f7c5 --- /dev/null +++ b/src/main/java/org/codedifferently/CalculateTax.java @@ -0,0 +1,87 @@ +package org.codedifferently; + +import java.util.Random; + +public class CalculateTax { + + + public int randomIdCode(){ + + Random random = new Random(); + + return random.nextInt(100, 999); + + + } + + public void receiptCode(String name, int iD){ + + String iDName = name.substring(0, 2); + + System.out.println("Your Receipt: " + iDName.toUpperCase() + "-" + iD); + + } + + + public double itemPrices (){ + Random random = new Random(); + + double item1 = random.nextDouble(10.00, 50.00); + double item2 = random.nextDouble(10.00, 50.00); + double item3 = random.nextDouble(10.00, 50.00); + + System.out.println("Item 1: " + Math.round(item1*100.0)/100.0); + System.out.println("Item 2: " + Math.round(item2*100.0)/100.0); + System.out.println("Item 3: " + Math.round(item3*100.0)/100.0); + double subTotal = item1 + item2 + item3; + + System.out.println("Subtotal: " + Math.round(subTotal*100.0)/100.0); + + return subTotal; + + } + + public double itemTax (double subTotal){ + + Random random = new Random(); + + int tax = random.nextInt(10); + + System.out.println("Item Tax: " + tax + "%"); + + double taxAmount = subTotal * ((double) tax /100); + + System.out.println("Final Total: " + Math.round(subTotal + taxAmount)); + + return subTotal + taxAmount; + + } + + + public void canThisNiggaAffordIt(double total, double budget){ + + + double finalTotal = total - budget; + + if(budget < total){ + System.out.println("You don't have enough. You need " + Math.round(finalTotal*100.0)/100.0 + " to complete order"); + + } + else{ + System.out.println("You have enough! your change is " + Math.abs(Math.round(finalTotal*100.0)/100.0 ) + "."); + } + + + + } + + + + + + + + + + +} diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 8a571aa..69f8df7 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -1,17 +1,40 @@ package org.codedifferently; +import java.util.Scanner; + //TIP To Run code, press or // click the icon in the gutter. public class Main { - static void main() { + public static void main(String[] args) { //TIP Press with your caret at the highlighted text // to see how IntelliJ IDEA suggests fixing it. - IO.println(String.format("Hello and welcome!")); + System.out.println("print"); + CalculateTax calculateTax = new CalculateTax(); + Scanner scanner = new Scanner(System.in); + + System.out.println("What is your Name?"); + String customerName = scanner.next(); + + System.out.println("What is your Budget?"); + double budget = scanner.nextDouble(); + + + + calculateTax.receiptCode(customerName, calculateTax.randomIdCode()); + double total = calculateTax.itemTax(calculateTax.itemPrices()); + calculateTax.canThisNiggaAffordIt(total,budget); + + + + + + + + + + + - 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); } } -} + From 2f3b0a6be065460f3d4f5b4c6bc294513c1dd0a2 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Sat, 7 Feb 2026 13:24:33 -0500 Subject: [PATCH 3/6] Title added --- src/main/java/org/codedifferently/Main.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 69f8df7..2295fd3 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -8,7 +8,7 @@ public class Main { public static void main(String[] args) { //TIP Press with your caret at the highlighted text // to see how IntelliJ IDEA suggests fixing it. - System.out.println("print"); + CalculateTax calculateTax = new CalculateTax(); Scanner scanner = new Scanner(System.in); @@ -18,6 +18,7 @@ public static void main(String[] args) { System.out.println("What is your Budget?"); double budget = scanner.nextDouble(); + System.out.println("----WELCOME TO THE DEV GROUP'S MYSTERY SHACK----"); calculateTax.receiptCode(customerName, calculateTax.randomIdCode()); From 893706fb342fa720c31d903fc955bd9a8ec42970 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Sun, 8 Feb 2026 21:02:38 -0500 Subject: [PATCH 4/6] Class name change + readme --- src/main/java/org/codedifferently/Main.java | 17 ++---- src/main/java/org/codedifferently/README.md | 61 +++++++++++++++++++ ...alculateTax.java => RecieptGenerator.java} | 4 +- 3 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 src/main/java/org/codedifferently/README.md rename src/main/java/org/codedifferently/{CalculateTax.java => RecieptGenerator.java} (94%) diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 2295fd3..f12692c 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -9,7 +9,7 @@ public static void main(String[] args) { //TIP Press with your caret at the highlighted text // to see how IntelliJ IDEA suggests fixing it. - CalculateTax calculateTax = new CalculateTax(); + RecieptGenerator calculateTax = new RecieptGenerator(); Scanner scanner = new Scanner(System.in); System.out.println("What is your Name?"); @@ -23,19 +23,10 @@ public static void main(String[] args) { calculateTax.receiptCode(customerName, calculateTax.randomIdCode()); double total = calculateTax.itemTax(calculateTax.itemPrices()); - calculateTax.canThisNiggaAffordIt(total,budget); + calculateTax.canYouAffordIt(total, budget); + scanner.close(); - - - - - - - - - - - } } +} diff --git a/src/main/java/org/codedifferently/README.md b/src/main/java/org/codedifferently/README.md new file mode 100644 index 0000000..28773e9 --- /dev/null +++ b/src/main/java/org/codedifferently/README.md @@ -0,0 +1,61 @@ +# Mystery Shack — Java + +This small Java console app simulates a checkout experience at **“The Dev Group’s Mystery Shack.”** +It asks for your name and budget, generates a random receipt ID, creates 3 random item prices, applies a random tax rate, then tells you if you can afford the total (or how much you’re short / what your change is). + +--- + +## What this program does + +1. Prompts the user for: + - **Name** + - **Budget** +2. Prints a “welcome” message. +3. Generates a **random receipt ID** and prints it in a receipt format. +4. Generates **3 random item prices** (between ~$10 and $50) and prints them. +5. Adds them up to a **subtotal**. +6. Generates a **random tax percent** (0%–9%), calculates the final total, and prints it. +7. Compares the final total to your budget and prints either: + - “You don’t have enough…” + amount needed, OR + - “You have enough!” + your change + +--- + +## Files / Classes + +### `Main.java` +This is the entry point (`main`) of the program. +- Creates a `CalculateTax` object +- Uses a `Scanner` to collect user input +- Calls methods in this order: + 1. `receiptCode(customerName, randomIdCode())` + 2. `itemPrices()` → returns subtotal + 3. `itemTax(subTotal)` → returns total with tax + 4. `canYouAffordIt(total, budget)` + +### `RecieptGenerator.java` +This class holds most of the “business logic”: + +- **`randomIdCode()`** + - Creates a random receipt number from **100 to 999** + +- **`receiptCode(String name, int id)`** + - Takes the **first 2 letters of the name**, uppercases them, and prints something like: + - `DE-472` + +- **`itemPrices()`** + - Generates 3 random item prices (roughly $10–$50) + - Prints each item and the subtotal + - Returns the subtotal as a `double` + +- **`itemTax(double subTotal)`** + - Picks a random tax rate from **0 to 9** + - Calculates tax amount and adds it to the subtotal + - Prints the tax percent and final total + - Returns the final total as a `double` + +- **`canYouAffordIt(double total, double budget)`** + - If budget < total → prints how much more you need + - Else → prints your change + +--- \ No newline at end of file diff --git a/src/main/java/org/codedifferently/CalculateTax.java b/src/main/java/org/codedifferently/RecieptGenerator.java similarity index 94% rename from src/main/java/org/codedifferently/CalculateTax.java rename to src/main/java/org/codedifferently/RecieptGenerator.java index 151f7c5..a63f0b6 100644 --- a/src/main/java/org/codedifferently/CalculateTax.java +++ b/src/main/java/org/codedifferently/RecieptGenerator.java @@ -2,7 +2,7 @@ import java.util.Random; -public class CalculateTax { +public class RecieptGenerator { public int randomIdCode(){ @@ -58,7 +58,7 @@ public double itemTax (double subTotal){ } - public void canThisNiggaAffordIt(double total, double budget){ + public void canYouAffordIt(double total, double budget){ double finalTotal = total - budget; From a43c43e2f3796d1500527ad4974abbf8ea5ef23b Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Mon, 9 Feb 2026 14:29:22 -0500 Subject: [PATCH 5/6] correction errors --- src/main/java/org/codedifferently/Main.java | 1 + src/main/java/org/codedifferently/RecieptGenerator.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index f12692c..c8b1af1 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -21,6 +21,7 @@ public static void main(String[] args) { System.out.println("----WELCOME TO THE DEV GROUP'S MYSTERY SHACK----"); + calculateTax.receiptCode(customerName, calculateTax.randomIdCode()); double total = calculateTax.itemTax(calculateTax.itemPrices()); calculateTax.canYouAffordIt(total, budget); diff --git a/src/main/java/org/codedifferently/RecieptGenerator.java b/src/main/java/org/codedifferently/RecieptGenerator.java index a63f0b6..2141daa 100644 --- a/src/main/java/org/codedifferently/RecieptGenerator.java +++ b/src/main/java/org/codedifferently/RecieptGenerator.java @@ -9,6 +9,8 @@ public int randomIdCode(){ Random random = new Random(); + + return random.nextInt(100, 999); @@ -18,6 +20,7 @@ public void receiptCode(String name, int iD){ String iDName = name.substring(0, 2); + System.out.println("ID: " + iD); System.out.println("Your Receipt: " + iDName.toUpperCase() + "-" + iD); } @@ -49,9 +52,9 @@ public double itemTax (double subTotal){ System.out.println("Item Tax: " + tax + "%"); - double taxAmount = subTotal * ((double) tax /100); + double taxAmount = subTotal * tax / 100; - System.out.println("Final Total: " + Math.round(subTotal + taxAmount)); + System.out.printf("Final Total: %.2f%n", (subTotal + taxAmount)); return subTotal + taxAmount; @@ -67,6 +70,8 @@ public void canYouAffordIt(double total, double budget){ System.out.println("You don't have enough. You need " + Math.round(finalTotal*100.0)/100.0 + " to complete order"); } + + else{ System.out.println("You have enough! your change is " + Math.abs(Math.round(finalTotal*100.0)/100.0 ) + "."); } From 6001d849263db5f2de787841d6edf0afd271c69a Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Tue, 10 Feb 2026 21:08:35 -0500 Subject: [PATCH 6/6] set 1 + Digit counter done --- src/main/java/org/codedifferently/RecieptGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/codedifferently/RecieptGenerator.java b/src/main/java/org/codedifferently/RecieptGenerator.java index 2141daa..7d3f5c7 100644 --- a/src/main/java/org/codedifferently/RecieptGenerator.java +++ b/src/main/java/org/codedifferently/RecieptGenerator.java @@ -1,7 +1,7 @@ package org.codedifferently; import java.util.Random; - +/// jj public class RecieptGenerator {