diff --git a/.DS_Store b/.DS_Store
index a70ee6b..d6f6f33 100644
Binary files a/.DS_Store and b/.DS_Store differ
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..40abf8d 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/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..6a72441 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,8 +9,8 @@
1.0-SNAPSHOT
- 25
- 25
+ 21
+ 21
UTF-8
diff --git a/src/main/java/org/codedifferently/Calculations.java b/src/main/java/org/codedifferently/Calculations.java
new file mode 100644
index 0000000..9137252
--- /dev/null
+++ b/src/main/java/org/codedifferently/Calculations.java
@@ -0,0 +1,34 @@
+package org.codedifferently;
+
+public class Calculations {
+ public static double finalTotalBill;
+
+
+
+ public static double calculateTax(double subTotal, double stateTax ){
+
+ return subTotal * stateTax;
+
+ }
+ public static double totalBeforeDiscount( double subTotal, double taxTotal){
+
+ return subTotal + taxTotal;
+ }
+
+ public static double subTotalBill (double firstItem, double secondItem, double thirdItem ) {
+
+ return firstItem + secondItem + thirdItem;
+ }
+
+ public static double finalTotalBill(double total, double discountAmt){
+
+ return total - discountAmt;
+ }
+
+ public static double roundedUp(double discountedTotal){
+
+ return Math.round(discountedTotal *100.0)/100.0;
+
+ }
+
+ }
diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java
index 8a571aa..33f5f4f 100644
--- a/src/main/java/org/codedifferently/Main.java
+++ b/src/main/java/org/codedifferently/Main.java
@@ -1,17 +1,88 @@
package org.codedifferently;
+import java.util.Random;
+import java.util.Scanner;
+
//TIP To Run code, press or
-// click the icon in the gutter.
+// 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) {
+ Scanner input = new Scanner( System.in);
+
+
+ System.out.println(" Welcome to Maxx's Boutique");
+
+ System.out.println("Enter your name: ");
+ String name = input.next();
+
+ System.out.println("Input budget: ");
+ double budget = input.nextDouble();;
+ input.nextLine();
+
+ System.out.println("Enter coupon code: ");
+ String code = input.next();
+
+ int idNumber = RandomGen.generateVisitId();
+ double stateTax = RandomGen.stateTax();
+ double discountAmt = RandomGen.discountTotal();
+
+ double firstItem = RandomGen.itemPrice();
+ double secondItem = RandomGen.itemPrice();
+ double thirdItem = RandomGen.itemPrice();
+
+ double subTotal = Calculations.subTotalBill(firstItem,secondItem,thirdItem);
+ double taxTotal = Calculations.calculateTax(subTotal,stateTax);
+ double total = Calculations.totalBeforeDiscount(subTotal, taxTotal);
+ discountAmt = Receipt.applyExtraCoupon(discountAmt,code);
+
+ double discountedTotal = Calculations.finalTotalBill(total,discountAmt);
+ double roundedTotal = Calculations.roundedUp(discountedTotal);
+
+ Receipt.printReceipt(
+ name,
+ code,
+ idNumber,
+ discountAmt,
+ firstItem,
+ secondItem,
+ thirdItem,
+ subTotal,
+ taxTotal,
+ roundedTotal
+ );
+
+ double remaining = budget - roundedTotal;
+ if(remaining >= 0) {
+ System.out.printf("You have $%.2f left in your budget.%n", remaining);
}
+ else {
+ System.out.printf("You are $%.2f over your budget!%n");
+
+ }
+ input.close();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
-}
+ }
+
diff --git a/src/main/java/org/codedifferently/RandomGen.java b/src/main/java/org/codedifferently/RandomGen.java
new file mode 100644
index 0000000..50de8a7
--- /dev/null
+++ b/src/main/java/org/codedifferently/RandomGen.java
@@ -0,0 +1,68 @@
+package org.codedifferently;
+import java.util.Random;
+
+
+public class RandomGen {
+ public static Random myRandom = new Random();
+
+
+
+ public static int generateVisitId() {
+ return myRandom.nextInt(9000 + 1000);
+
+ }
+
+
+ public static double itemPrice() {
+ return myRandom.nextDouble(3.00,30.00 );
+
+ }
+
+ public static double stateTax() {
+ return myRandom.nextDouble(0.005, 0.007 );
+
+ }
+
+ public static double discountTotal() {
+ return myRandom.nextDouble(1.00, 5.00 );
+
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/org/codedifferently/Receipt.java b/src/main/java/org/codedifferently/Receipt.java
new file mode 100644
index 0000000..62be55c
--- /dev/null
+++ b/src/main/java/org/codedifferently/Receipt.java
@@ -0,0 +1,76 @@
+package org.codedifferently;
+
+public class Receipt {
+
+ public static String generateRecieptId(String name, int idNumber) {
+ String cleanName = name.trim().toUpperCase();
+ String prefix = cleanName.substring(0, Math.min(3, cleanName.length()));
+ return prefix + idNumber;
+ }
+
+ public static boolean isCouponValid(String code) {
+ String cleanedCoupon = code.trim();
+ return cleanedCoupon.equalsIgnoreCase("SAVE10")
+ || cleanedCoupon.equalsIgnoreCase("VIP");
+ }
+
+ public static double applyExtraCoupon(double discountAmt, String code) {
+ if (isCouponValid(code)) {
+ return discountAmt + 2.00;
+ }
+ return discountAmt;
+ }
+
+ public static void couponMessage(String code) {
+ if (isCouponValid(code)) {
+ System.out.println("Congratulations !!! You earned 2.00 off.");
+ } else {
+ System.out.println("Sorry this isnt a valid code.");
+ }
+ }
+
+
+ public static void printReceipt(
+ String name,
+ String code,
+ int idNumber,
+ double discountAmt,
+ double firstItem,
+ double secondItem,
+ double thirdItem,
+ double subTotal,
+ double taxTotal,
+ double roundedTotal) {
+
+ String customerId = generateRecieptId(name, idNumber);
+
+ System.out.println("\n=================================");
+ System.out.println(" Maxx's Boutique");
+ System.out.println("===================================");
+ System.out.println("Customer Name: " + name);
+ System.out.println("Receipt Id: " + customerId);
+ System.out.println("Coupon Entered: " + code);
+
+ couponMessage(code);
+ System.out.println();
+
+ System.out.printf("Item 1: $%.2f%n", firstItem);
+ System.out.printf("Item 2: $%.2f%n", secondItem);
+ System.out.printf("Item 3: $%.2f%n", thirdItem);
+
+ System.out.printf("%nSubtotal: $%.2f%n", subTotal);
+ System.out.printf("Tax due: $%.2f%n", taxTotal);
+ System.out.printf("You saved: $%.2f%n", discountAmt);
+ System.out.printf("Total: $%.2f%n", roundedTotal);
+
+ System.out.println("===========================\n");
+ }
+}
+
+
+
+
+
+
+
+