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..c90834f 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
index 36361c6..3007dae 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 9c12bdd..2362803 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+[](https://classroom.github.com/a/6tlCTWq0)
# 🧾 Mystery Receipt Generator (Java CLI Project)
## Overview
diff --git a/pom.xml b/pom.xml
index 24314b9..f61f926 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,17 +1,20 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+https://maven.apache.org/xsd/maven-4.0.0.xsd">
+
4.0.0
- org.codedifferently
- untitled
+ com.kennedy
+ java-receipt-generator
1.0-SNAPSHOT
- 25
- 25
+ 21
+ 21
UTF-8
-
\ No newline at end of file
+
+
diff --git a/src/main/java/CodeGenerator.java b/src/main/java/CodeGenerator.java
new file mode 100644
index 0000000..3d78ceb
--- /dev/null
+++ b/src/main/java/CodeGenerator.java
@@ -0,0 +1,27 @@
+public class CodeGenerator {
+
+ public static String buildReceiptCode(String name, int visitId) {
+
+
+ String cleaned = (name == null) ? "GUEST" : name.trim(); // trim
+ String upper = cleaned.toUpperCase(); // toUpperCase
+
+ String key;
+
+ if (upper.length() >= 3) { // length
+
+ key = upper.substring(0, 3); // substring
+ } else {
+
+ key = (upper + "XXX").substring(0, 3);
+ }
+
+ char marker = !upper.isEmpty() ? upper.charAt(0) : 'G'; // charAt
+
+ return key + "-" + marker + "-" + visitId;
+
+
+
+ }
+}
+
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
new file mode 100644
index 0000000..e1ea19b
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,6 @@
+public class Main {
+
+ public static void main(String[] args) {
+ ReceiptApp.run();
+ }
+}
diff --git a/src/main/java/PriceGenerator.java b/src/main/java/PriceGenerator.java
new file mode 100644
index 0000000..ddb9b57
--- /dev/null
+++ b/src/main/java/PriceGenerator.java
@@ -0,0 +1,72 @@
+import java.util.Random;
+
+public class PriceGenerator {
+
+ public static int generateVisitId(Random random) {
+ return 1000 + random.nextInt(9000); // 1000–9999
+ }
+
+ public static double[] generateItemPrices(Random random) {
+
+
+ double[] items = new double[3];
+ for (int i = 0; i < items.length; i++) {
+
+
+ // $2.50 to $35.00
+ double raw = 2.50 + (32.50 * random.nextDouble());
+ items[i] = roundMoney(raw);
+ }
+ return items;
+ }
+
+ public static double generateTaxRate(Random random) {
+ // 4% to 9%
+ return 0.04 + (0.05 * random.nextDouble());
+ }
+
+ public static double subtotal(double[] items) {
+ double sum = 0;
+
+ for (double p : items) sum += p;
+
+ return roundMoney(sum);
+ }
+
+ // Lucky visit bonus (if last digit is 7 => 7% off)
+ public static double luckyVisitBonusDiscount(int visitId, double subtotal) {
+ if (visitId % 10 == 7) {
+ return roundMoney(subtotal * 0.07);
+ }
+ return 0.0;
+ }
+
+ // Mystery fee or discount
+ public static double mysteryAdjustment(Random random, double subtotal) {
+ boolean fee = random.nextBoolean();
+
+ double percent = 0.02 + (0.04 * random.nextDouble()); // 2%..6%
+
+ double amount = roundMoney(subtotal * percent);
+
+ return fee ? amount : -amount;
+ }
+
+ // VIP coupon randomly works + case-insensitive check
+ public static double couponDiscount(Random random, String couponCode, double subtotal) {
+ if (couponCode != null && couponCode.trim().equalsIgnoreCase("VIP")) {
+ boolean works = random.nextInt(10) < 6;// 60%
+ if (works) {
+ return roundMoney(subtotal * 0.15);
+ }
+ }
+ return 0.0;
+ }
+
+ public static double roundMoney(double value) {
+ return Math.round(value * 100.0) / 100.0;
+
+
+
+ }
+}
diff --git a/src/main/java/README.md b/src/main/java/README.md
new file mode 100644
index 0000000..d574cd6
--- /dev/null
+++ b/src/main/java/README.md
@@ -0,0 +1,21 @@
+# RANDOM RECEIPT GENERATOR
+## Developer : Kenny Edelin
+
+### Main.java
+In this class, you will see my main method that allows my receipt to RUN.
+
+### Receipt.java
+In this class, you will see sections for User Inout, as well as Random Data generations. User Input, consist of my three question inquiring about Name, Budget and Vip code.
+
+### PriceGenerator.java
+In this class, you will see mostly random data generators. Generating item prices, as well as random discounts, mystery adjustments, tax rates and rounded totals. Also variable and output types that I need.
+
+### CodeGenerator.java
+This class consist of if/else statements that build the receipt code. These if/else statements are based on the length of user input. There are also return statements to specify what my output should be.
+
+### ReceiptGenerator.java
+This class has all contents that the receipt includes, which in return calls for a lot of print statements. Also, I tried my best to separate each section on the receipt with hyphens.
+
+### CLOSING
+Thank you for using and analyzing my Random Receipt Generator with me!
+!
diff --git a/src/main/java/ReceiptApp.java b/src/main/java/ReceiptApp.java
new file mode 100644
index 0000000..bcdb380
--- /dev/null
+++ b/src/main/java/ReceiptApp.java
@@ -0,0 +1,61 @@
+import java.util.Random;
+import java.util.Scanner;
+
+public class ReceiptApp {
+
+ public static void run() {
+ Scanner scanner = new Scanner(System.in);
+ Random random = new Random();
+
+ // User Input
+ System.out.print("What is your name? ");
+ String name = scanner.nextLine().trim();
+
+ System.out.print("What is your budget? ");
+ double budget = scanner.nextDouble();
+ scanner.nextLine();
+
+ System.out.print("What is your coupon code: ");
+ String coupon = scanner.nextLine();
+
+ // Random Input
+ int visitId = PriceGenerator.generateVisitId(random);
+ double[] items = PriceGenerator.generateItemPrices(random);
+ double taxRate = PriceGenerator.generateTaxRate(random);
+
+ String receiptCode = CodeGenerator.buildReceiptCode(name, visitId);
+
+ double subtotal = PriceGenerator.subtotal(items);
+ double tax = subtotal * taxRate;
+
+ double luckyDiscount = PriceGenerator.luckyVisitBonusDiscount(visitId, subtotal);
+ double mystery = PriceGenerator.mysteryAdjustment(random, subtotal);
+ double couponDiscount = PriceGenerator.couponDiscount(random, coupon, subtotal);
+
+ double total = subtotal + tax + mystery - luckyDiscount - couponDiscount;
+ total = PriceGenerator.roundMoney(Math.max(0, total));
+
+ double remaining = PriceGenerator.roundMoney(budget - total);
+
+ ReceiptPrinter.print(
+ "Ken's Grocery Store",
+ name,
+ visitId,
+ receiptCode,
+ items,
+ subtotal,
+ taxRate,
+ tax,
+ mystery,
+ luckyDiscount,
+ coupon,
+ couponDiscount,
+ total,
+ budget,
+ remaining
+ );
+
+ scanner.close();
+ }
+}
+
diff --git a/src/main/java/ReceiptPrinter.java b/src/main/java/ReceiptPrinter.java
new file mode 100644
index 0000000..e735c6b
--- /dev/null
+++ b/src/main/java/ReceiptPrinter.java
@@ -0,0 +1,94 @@
+public class ReceiptPrinter {
+
+ public static void print(
+
+
+ String storeName,
+
+ String customerName,
+
+ int visitId,
+
+ String receiptCode,
+
+ double[] items,
+ double subtotal,
+ double taxRate,
+ double tax,
+ double mysteryAdjustment,
+ double luckyBonusDiscount,
+
+ String coupon,
+
+ double couponDiscount,
+ double total,
+ double budget,
+ double remaining
+
+
+ ) {
+ System.out.println();
+
+ System.out.println("----- Welcome to " + storeName + " -----");
+
+ System.out.println("Customer: " + customerName);
+
+ System.out.println("Visit ID: " + visitId);
+
+ System.out.println("Receipt Code: " + receiptCode);
+
+ System.out.println("----------------------------------------");
+
+ for (int i = 0; i < items.length; i++) {
+ System.out.printf("Item %d: $%.2f%n", (i + 1), items[i]);
+ }
+
+ System.out.println("----------------------------------------");
+
+ System.out.printf("Subtotal: $%.2f%n", subtotal);
+
+ System.out.printf("Tax (%.1f%%): $%.2f%n", taxRate * 100.0, tax);
+
+ if (mysteryAdjustment > 0) {
+ System.out.printf("Mystery Fee: +$%.2f%n", mysteryAdjustment);
+
+ } else if (mysteryAdjustment < 0) {
+ System.out.printf("Mystery Discount: -$%.2f%n", Math.abs(mysteryAdjustment));
+ }
+
+ if (luckyBonusDiscount > 0) {
+ System.out.printf("Lucky Visit Bonus: -$%.2f%n", luckyBonusDiscount);
+ }
+
+ if (couponDiscount > 0) {
+ System.out.printf("Coupon (%s) Applied: -$%.2f%n", coupon.trim().toUpperCase(), couponDiscount);
+ } else {
+ System.out.printf("Coupon (%s): Not Applied%n", coupon.trim());
+ }
+
+ System.out.println("----------------------------------------");
+
+ System.out.printf("FINAL TOTAL: $%.2f%n", total);
+
+ System.out.printf("Budget: $%.2f%n", budget);
+
+ if (remaining >= 0) {
+ System.out.printf("Budget Remaining: $%.2f%n", remaining);
+ if (remaining < 5) {
+ System.out.println("WARNING: Tight budget. You're cutting it close.");
+ }
+ } else {
+ System.out.printf("Short By: $%.2f%n", Math.abs(remaining));
+
+ System.out.println("WARNING: You do not have enough budget to complete this order.");
+
+ }
+
+ System.out.println("----------------------------------------");
+
+
+
+
+ System.out.println("Thank you. Come again.");
+ }
+}
diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java
deleted file mode 100644
index 8a571aa..0000000
--- a/src/main/java/org/codedifferently/Main.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.codedifferently;
-
-//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);
- }
- }
-}