Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
12 changes: 12 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -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!


37 changes: 25 additions & 12 deletions src/main/java/org/codedifferently/Main.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package org.codedifferently;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
import java.util.Scanner;

public class Main {
static void main() {
//TIP Press <shortcut actionId="ShowIntentionActions"/> 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 <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
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());
}






}

}
75 changes: 75 additions & 0 deletions src/main/java/org/codedifferently/recieptcalculator.java
Original file line number Diff line number Diff line change
@@ -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;
}

}