From d30c0273351e03e44ed8e55699abc692e460db90 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 20:34:41 +0000 Subject: [PATCH 1/5] 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 53701a0a6e637d8811557ddda98f6081bbf7a43c Mon Sep 17 00:00:00 2001 From: glenntyson Date: Mon, 9 Feb 2026 07:03:02 -0500 Subject: [PATCH 2/5] Made the random class for calculations --- .DS_Store | Bin 6148 -> 6148 bytes .idea/aws.xml | 11 +++++++++ .idea/copilot.data.migration.agent.xml | 6 +++++ .idea/copilot.data.migration.ask.xml | 6 +++++ .idea/copilot.data.migration.ask2agent.xml | 6 +++++ .idea/copilot.data.migration.edit.xml | 6 +++++ .idea/encodings.xml | 2 ++ .idea/misc.xml | 3 ++- .idea/modules.xml | 8 ------- src/main/java/org/codedifferently/Main.java | 14 +++--------- src/main/java/org/codedifferently/nameId.java | 8 +++++++ .../java/org/codedifferently/randomMath.java | 21 ++++++++++++++++++ 12 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 .idea/aws.xml create mode 100644 .idea/copilot.data.migration.agent.xml create mode 100644 .idea/copilot.data.migration.ask.xml create mode 100644 .idea/copilot.data.migration.ask2agent.xml create mode 100644 .idea/copilot.data.migration.edit.xml delete mode 100644 .idea/modules.xml create mode 100644 src/main/java/org/codedifferently/nameId.java create mode 100644 src/main/java/org/codedifferently/randomMath.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/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.agent.xml b/.idea/copilot.data.migration.agent.xml new file mode 100644 index 0000000..4ea72a9 --- /dev/null +++ b/.idea/copilot.data.migration.agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.ask.xml b/.idea/copilot.data.migration.ask.xml new file mode 100644 index 0000000..7ef04e2 --- /dev/null +++ b/.idea/copilot.data.migration.ask.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.ask2agent.xml b/.idea/copilot.data.migration.ask2agent.xml new file mode 100644 index 0000000..1f2ea11 --- /dev/null +++ b/.idea/copilot.data.migration.ask2agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.edit.xml b/.idea/copilot.data.migration.edit.xml new file mode 100644 index 0000000..8648f94 --- /dev/null +++ b/.idea/copilot.data.migration.edit.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file 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 b28c0fb..881fc70 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/Main.java b/src/main/java/org/codedifferently/Main.java index 8a571aa..ddbf819 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -3,15 +3,7 @@ //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!")); - - 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); - } + public static void main(String[] args) { + System.out.println("Hello Code Differently!"); } -} +} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/nameId.java b/src/main/java/org/codedifferently/nameId.java new file mode 100644 index 0000000..9908eff --- /dev/null +++ b/src/main/java/org/codedifferently/nameId.java @@ -0,0 +1,8 @@ +package org.codedifferently; + + + +public class nameId { + + +} diff --git a/src/main/java/org/codedifferently/randomMath.java b/src/main/java/org/codedifferently/randomMath.java new file mode 100644 index 0000000..096c350 --- /dev/null +++ b/src/main/java/org/codedifferently/randomMath.java @@ -0,0 +1,21 @@ +package org.codedifferently; + +import java.util.Random; + +public class randomMath { + + public static int visittoryid(Random random){ + return random.nextInt(90000)+10000; + } + public static double itemPrice(Random random){ + double price = random.nextDouble() * 20 +5; + return Math.round(price*100.0)/100.0; + } + public static double subTotal(double a,double b,double c){ + double subTotal = a+b+c; + return Math.round(subTotal*100.0)/100.0; + } + public static double tax(double subTotal, double rate){ + return Math.round(subTotal*rate*100.0)/100.0; + } +} From dfc7e5b55c5b1a54f5e85b0ed8fbf4dc3d00d158 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Mon, 9 Feb 2026 07:12:16 -0500 Subject: [PATCH 3/5] Made customer id and put in when a customer is picked --- src/main/java/org/codedifferently/nameId.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/org/codedifferently/nameId.java b/src/main/java/org/codedifferently/nameId.java index 9908eff..defe17d 100644 --- a/src/main/java/org/codedifferently/nameId.java +++ b/src/main/java/org/codedifferently/nameId.java @@ -1,8 +1,28 @@ package org.codedifferently; +import java.util.Random; public class nameId { + public static String code(String name, int id) { + String personName = name.trim().toUpperCase(); + return personName.charAt(0) + personName.substring(personName.length() - 1) + id; + + } +public static String tag(Random random){ + int pick = random.nextInt(4); + if (pick==0){ + return "Did you win?"; + } else if (pick==1){ + return "Better luck next time!"; + } + else if (pick==2){ + return "You are a winner!"; + } + else { + return "Try again!"; + } +} } From 45c1e8e12607f7d75a2e6f15542f232d43080220 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Mon, 9 Feb 2026 07:49:40 -0500 Subject: [PATCH 4/5] Final commit with my main method string method and random method --- src/main/java/org/codedifferently/Main.java | 62 ++++++++++++++++++- src/main/java/org/codedifferently/ReadMe.md | 11 ++++ src/main/java/org/codedifferently/nameId.java | 12 +++- .../java/org/codedifferently/randomMath.java | 8 ++- 4 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/codedifferently/ReadMe.md diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index ddbf819..e9b4056 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -1,9 +1,65 @@ package org.codedifferently; -//TIP To Run code, press or -// click the icon in the gutter. +import java.util.Random; +import java.util.Scanner; + + public class Main { public static void main(String[] args) { - System.out.println("Hello Code Differently!"); + // Scanner to add inputs + Scanner scanner = new Scanner(System.in); + Random random = new Random(); + + + System.out.println("Enter your name please: "); + String name = scanner.nextLine(); + + + System.out.println("Enter how much you are spending"); + double budget = scanner.nextDouble(); + scanner.nextLine(); + + + System.out.println("Enter coupon code if you have one"); + String coupon = scanner.nextLine(); + scanner.close(); +//I called the methods from the other classes to generate the random values and do the calculations + int visited = randomMath.visitor(random); + double item1 = randomMath.itemPrice(random); + double item2 = randomMath.itemPrice(random); + double item3 = randomMath.itemPrice(random); + + double subTotal = randomMath.subTotal(item1, item2, item3); + + double taxRate = Math.max(0.05, random.nextDouble() * 0.1); + double tax = randomMath.tax(subTotal, taxRate); + + double total = subTotal + tax; + total = nameId.couponCode(coupon, total); + total = Math.round(total * 100.0) / 100.0; + + String code = nameId.code(name, visited); + String tag = nameId.tag(random); +// I added the print statements to display the reciept and the results of the calculations. + System.out.println("Welcome to the winning store : " + name); + System.out.println("Your visit ID is: " + visited); + System.out.println("Your code for your reciept is: " + code); + System.out.println("||||||||||||||||||||||"); + System.out.println("Item 1: $" + item1); + System.out.println("Item 2: $" + item2); + System.out.println("Item 3: $" + item3); + System.out.println("''''''''''''''''''''''''"); + System.out.println("Subtotal: $" + subTotal); + System.out.println("Tax: $" + tax); + System.out.println("Total: $" + (subTotal + tax)); +// I added the if statement to compare the total with the budget and display the appropriate message. + if (budget >= total) { + System.out.println("Money remaining: $" + + (Math.round((budget - total) * 100.0) / 100.0)); + } else { + System.out.println("You are over budget by: $" + + (Math.round((total - budget) * 100.0) / 100.0)); + } + System.out.println("\n" + tag); } } \ No newline at end of file diff --git a/src/main/java/org/codedifferently/ReadMe.md b/src/main/java/org/codedifferently/ReadMe.md new file mode 100644 index 0000000..6f68bf4 --- /dev/null +++ b/src/main/java/org/codedifferently/ReadMe.md @@ -0,0 +1,11 @@ +I made a read random Math file to hold all my math in methods in so that I can all them to main. + + +Then I made a read random String file to hold all my String methods in so that I can call them to main. + + +Then I made a read random main file to call all the methods from the other two files and print the receipt. + +I did some math to calculate the subtotal, tax, discounts, and total. I also did some math to calculate the budget remaining or how much the user is short. + +I add commits to all my files to explain what each method does and what each part of the code is doing. \ No newline at end of file diff --git a/src/main/java/org/codedifferently/nameId.java b/src/main/java/org/codedifferently/nameId.java index defe17d..05adf33 100644 --- a/src/main/java/org/codedifferently/nameId.java +++ b/src/main/java/org/codedifferently/nameId.java @@ -4,13 +4,21 @@ import java.util.Random; public class nameId { - + // I added the method to apply the coupon code and calculate the total after the discount is applied. + public static double couponCode(String coupon,double total){ + if (coupon.trim().equalsIgnoreCase("Vip0")){ + total -= Math.min(10,total*0.1); + } + return Math.round(Math.abs(total)*100.0)/100.0; + } +//I added the method to generate the code for the reciept using the name and the visit ID. public static String code(String name, int id) { String personName = name.trim().toUpperCase(); return personName.charAt(0) + personName.substring(personName.length() - 1) + id; } -public static String tag(Random random){ +// I added the method to generate a random tag for the reciept using the Random class. + public static String tag(Random random){ int pick = random.nextInt(4); if (pick==0){ return "Did you win?"; diff --git a/src/main/java/org/codedifferently/randomMath.java b/src/main/java/org/codedifferently/randomMath.java index 096c350..19dc309 100644 --- a/src/main/java/org/codedifferently/randomMath.java +++ b/src/main/java/org/codedifferently/randomMath.java @@ -3,18 +3,22 @@ import java.util.Random; public class randomMath { - - public static int visittoryid(Random random){ +// I added the method to generate a random visit ID using the Random class. + public static int visitor(Random random){ return random.nextInt(90000)+10000; } + // I added the method to generate a random price for each item using the Random class and rounding it to 2 decimal places. public static double itemPrice(Random random){ double price = random.nextDouble() * 20 +5; return Math.round(price*100.0)/100.0; } + // I added the method to calculate the subtotal by adding the prices of the three items and rounding it to 2 decimal places. public static double subTotal(double a,double b,double c){ double subTotal = a+b+c; return Math.round(subTotal*100.0)/100.0; } + + // I added the method to calculate the tax by multiplying the subtotal by the tax rate and rounding it to 2 decimal places. public static double tax(double subTotal, double rate){ return Math.round(subTotal*rate*100.0)/100.0; } From fd7c530fd9e35cfbeab6c00ec3c11945ff4bf8b8 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Mon, 9 Feb 2026 09:04:41 -0500 Subject: [PATCH 5/5] Fixed readMe --- .idea/misc.xml | 1 - src/main/java/org/codedifferently/ReadMe.md | 36 ++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 881fc70..db528c8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/src/main/java/org/codedifferently/ReadMe.md b/src/main/java/org/codedifferently/ReadMe.md index 6f68bf4..5dfc3a4 100644 --- a/src/main/java/org/codedifferently/ReadMe.md +++ b/src/main/java/org/codedifferently/ReadMe.md @@ -8,4 +8,38 @@ Then I made a read random main file to call all the methods from the other two f I did some math to calculate the subtotal, tax, discounts, and total. I also did some math to calculate the budget remaining or how much the user is short. -I add commits to all my files to explain what each method does and what each part of the code is doing. \ No newline at end of file +I add commits to all my files to explain what each method does and what each part of the code is doing. + + +Enter your name please: + +glenn + +Enter how much you are spending + +50 + +Enter coupon code if you have one + +vip0 + +Welcome to the winning store : glenn + +Your visit ID is: 82656 + +Your code for your reciept is: GN82656 + +|||||||||||||||||||||| + +Item 1: $24.46 + +Item 2: $12.24 + +Item 3: $18.47 + +'''''''''''''''''''''''' + +Subtotal: $55.17 +Tax: $3.32 +Total: $58.49 +You are over budget by: $2.64 \ No newline at end of file