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..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/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/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/README.md b/src/README.md new file mode 100644 index 0000000..872be68 --- /dev/null +++ b/src/README.md @@ -0,0 +1,12 @@ +# Welcome to the overview of my random receipt generator! +here we will be discussing how it works, how to use it and providing example output +This calculator takes in a value for name, budget and if you are a rewards member when prompted. +It then generates a random reciept including tax, tax rate, price of three different items and the price rounded. + + +## How does it work? +Glad you asked. After the system prompts the user for input the reciept calculator class does the heavy lifting. +The random class randomizes all the output. Not before we check to see if the user is a rewards member. if they are they +recieve 50 percent off! let me know what you think! + + diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 8a571aa..5481f0d 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -1,17 +1,30 @@ package org.codedifferently; -//TIP To Run code, press or -// click the icon in the gutter. +import java.util.Scanner; + 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) { + recieptcalculator recieptcalculator = new recieptcalculator(); + Scanner scanner = new Scanner(System.in); + System.out.println("Welcome to Masons Tech Emporium!"); + System.out.println("What is your name"); + String name = scanner.nextLine(); + System.out.println("What is your budget:"); + double budget = scanner.nextDouble(); + System.out.println("Enter your 5 digit rewards number"); + double rewardnumber = scanner.nextInt(); + if (rewardnumber == recieptcalculator.rewardsmemnum){ + recieptcalculator.rewardmember = true; + System.out.println(recieptcalculator.generatethereceipt()); + } else { + System.out.println(recieptcalculator.generatethereceipt()); + } + + + + + + } + } diff --git a/src/main/java/org/codedifferently/recieptcalculator.java b/src/main/java/org/codedifferently/recieptcalculator.java new file mode 100644 index 0000000..d06621e --- /dev/null +++ b/src/main/java/org/codedifferently/recieptcalculator.java @@ -0,0 +1,75 @@ +package org.codedifferently; + +import java.util.Random; + +public class recieptcalculator { + + private int itemid; + private double itemprice; + private double taxrate; + private double tax; + private double item2price; + private double item3price; + public boolean rewardmember; + public double memberpricing; + public int rewardsmemnum = 00000; + public recieptcalculator() { + Random random = new Random(); + itemid = random.nextInt(1000) + 100; + taxrate = random.nextInt((7)) + 3 / 100.0; + itemprice = random.nextInt(400) + 19; + item2price = random.nextInt(30) + 1; + item3price = random.nextInt(60) + 4; + + } + + public double calculatetax() { + return Round((itemprice + item2price + item3price) * taxrate) / 100; + } + + public double calculatetotal() { + + return itemprice + item2price + item3price + calculatetax() + tax; + } + + public String generatethereceipt() { + String reciept = ""; + + reciept += "Item ID: " + itemid + "\n"; + reciept += "Price: $" + (itemprice) + "\n"; + reciept += "Price: $" + (item2price) + "\n"; + reciept += "Price: $" + (item3price) + "\n"; + reciept += "Tax rate:" + (taxrate) + "\n"; + reciept += "Tax:" + calculatetax() + "\n"; + recieptcalculator rc = new recieptcalculator(); + Main main = new Main(); + + + if (rewardmember == true) { + memberpricing = calculatetotal() / 2; + reciept += "Total: $" + memberpricing + "\n"; + + } else { + reciept += "Total: $" + calculatetotal() + "\n"; + } + if (rewardmember == true) { + memberpricing = calculatetotal() / 2; + reciept += "Total: $" + " " + "(Rounded):" + Round(memberpricing) + "\n"; + + } else { + reciept += "Total: $(Rounded):" + Round(calculatetotal()) + "\n"; + + + } + return reciept; + + } + + private double Round(double valuerounded) { + return Math.round(valuerounded * 100) / 100; + } + +} + + +