Skip to content

Latest commit

 

History

History
45 lines (24 loc) · 2.22 KB

File metadata and controls

45 lines (24 loc) · 2.22 KB

🧾 Walmart Receipt Generator

Overview

This project uses the Random, String, and Math classes to generate a randomized receipt that simulates the experience of checking out at Walmart.


Main Class

The Main class serves as the central hub of the project. It calls methods from the UserInput class to gather the user’s first name, last name, coupon code, and budget. Using this information, the program generates randomized tax rates and discount rates from MathCalc and StringLogic to calculate the final total.


MathCalc Class

The MathCalc class handles all math-related calculations using the Math class. It includes a method called generateRandomNumber() that generates a random number within a specified lower and upper bound. This custom random number logic is also used in the generateCouponDiscount() and generateTaxRate() methods, where percentage values are converted to decimals before being returned.

The class also calculates the final purchase total using the calculateFinalTotal() method, which takes the subtotal, tax rate, and coupon discount as parameters. Lastly, the calculateRemainingBudget() method determines how much budget remains after the purchase.


StringLogic Class

The StringLogic class contains all string-related operations using the String class. It generates a receipt code by combining the first three letters of the user’s first and last name with a randomly generated number. This class also validates coupon codes by checking whether the input starts with the letter c and contains a hyphen.


UserInput Class

All user input is handled within the UserInput class. Each method prompts the user for input and stores it as either a String for the first name, last name, and coupon code, or a double for the budget. These values are then passed back to the Main class for processing and calculation.


Sample Output

Below are screenshots showcasing example outputs generated by the program.

image

Here we have my name for the input Name, as well as a budget, and the correct coupon code.

image

In this image, we display the final result of the receipt code, an incorrect coupon was implemented here.