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..b4060f3 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/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 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); - } - } -} diff --git a/src/main/java/org/codedifferently/ReceiptApp.java b/src/main/java/org/codedifferently/ReceiptApp.java new file mode 100644 index 0000000..372cf10 --- /dev/null +++ b/src/main/java/org/codedifferently/ReceiptApp.java @@ -0,0 +1,70 @@ +package org.codedifferently; + +import java.util.Random; +import java.util.Scanner; + +public class ReceiptApp { + + public static double roundMoney(Double amount){ + return Math.round(amount * 100.0) / 100.0; + } + + public static void main(String[] args) { + + // ==== USER INPUT ==== + Scanner scanner = new Scanner(System.in); + + System.out.println("Enter your name: "); + + String name = scanner.nextLine(); + + System.out.println("Enter your budget: "); + + + String budgetText = scanner.nextLine(); + + double budget = Double.parseDouble(budgetText); + + System.out.println("Enter a coupon code: "); + + String couponCode = scanner.nextLine(); + + + Random rand = new Random(); + + int visitId = 1000 + rand.nextInt(9000); + + double item1 = 5 + rand.nextDouble() * 35; + double item2 = 10 + rand.nextDouble() * 70; + double item3 = 3 + rand.nextDouble() * 22; + + item1 = roundMoney(item1); + + item2 = roundMoney(item2); + + item3 = roundMoney(item3); + + double subTotal = item1 + item2 + item3; + subTotal = roundMoney(subTotal); + + + + + + System.out.println(); + System.out.println("Welcome " + name + "!"); + System.out.println("Budget entered: " + budget); + System.out.println("Coupon entered: " + couponCode); + + System.out.println("\n--- TEST OUTPUT ---"); + System.out.println("Visit ID: " + visitId); + System.out.println("Item 1: " + item1); + System.out.println("Item 2: " + item2); + System.out.println("Item 3: " + item3); + System.out.println("Subtotal: $" + subTotal); + + + scanner.close(); + + } +}