You are building a mini suite of real-world utilities using Java’s Math class.
- No starter code is provided. You write everything from scratch.
- Each assignment must be its own Java class with a
mainmethod. - Your programs must compile and run.
- Output must be clearly labeled and readable.
Create a folder named src/ and place your .java files inside it: If src is already there, you do not have to create it
src/
- TipTaxCalculator.java
- Read assignment 01, build it, run it
- Commit
You must complete your work on your own branch, not on main.
- This is how real teams work
- It protects the
mainbranch - It makes your work easier to review
From the project root, open the terminal and run:
git checkout -b yourname-math-practiceExample:
git checkout -b coreye-math-practiceThis creates a new branch and switches you to it.
Run:
git branchYou should see a * next to your branch name:
* coreye-math-practice
main
If you see main starred, you are on the wrong branch.
- Create your
srcfolder - Create your Java files
- Write and test your code
- Commit your changes
Example commit:
git add .
git commit -m "Complete Math practice assignments"git push -u origin yourname-math-practiceAfter this, your branch will appear on GitHub.
- Do NOT commit directly to
main - Do NOT delete your branch
- Do NOT rename your branch after pushing
This project is a beginner-friendly Java application that simulates a real-world restaurant bill calculator. You will collect user input, perform calculations using methods, and format output clearly.
The goal is to practice:
- Using
Scannerfor user input - Writing and calling your own methods
- Working with return values
- Using the Java
Mathclass correctly - Structuring code the way real developers do
By completing this project, you will be able to:
- Collect numeric input from a user using
Scanner - Create custom
staticmethods outside ofmain - Pass data into methods using parameters
- Return values from methods and use them in
main - Apply percentage math correctly
- Use
Math.round()to round numeric values - Organize Java code for readability and reuse
You will build a console-based Tip & Tax Calculator.
The program will:
-
Ask the user for:
- Bill amount
- Tax rate (percentage)
- Tip rate (percentage)
-
Calculate:
- Tax amount
- Tip amount
- Total bill
-
Round the final total to the nearest whole dollar
-
Display all results with clear labels
Your project must include:
src/
└── TipTaxCalculator.java
- The class name must match the file name
- All Java files must be placed inside the
srcfolder - The
srcfolder must be marked as a Sources Root in IntelliJ
This project is designed to move you away from writing all logic in main.
-
Create multiple custom methods outside of
main -
Call those methods from
main -
Ensure your methods:
- Accept parameters
- Return values
-
Keep
mainresponsible for:- User input
- Calling methods
- Printing results
Your program should include methods similar to:
- A method to calculate tax
- A method to calculate tip
- A method to calculate the total bill
- A method to round the total
Each method should do one clear job.
You must use Scanner to collect input from the user.
Prompt the user for:
- Bill amount (double)
- Tax rate percentage (double)
- Tip rate percentage (double)
Hard-coded values are not allowed.
You must:
-
Perform percentage calculations using:
amount * (percent / 100) -
Use
Math.round()to round the final total bill -
Store the rounded result in a variable
Reminder:
Math.round()returns along
Your program must print all of the following with clear labels:
- Bill amount
- Tax amount
- Tip amount
- Total bill (raw)
- Total bill (rounded)
Each value should appear on its own line.
Enter bill amount: 45.50
Enter tax rate (%): 8
Enter tip rate (%): 18
Bill amount: 45.5
Tax amount: 3.64
Tip amount: 8.19
Total (raw): 57.33
Total (rounded): 57
Your output may differ depending on user input.
git add .
git commit -m "Complete Tip & Tax Calculator"
git push -u origin yourname-tip-tax- Do NOT put all calculations directly inside
main - Do NOT hard-code bill values
- Do NOT remove method return values
- Do NOT commit directly to
main
This project mirrors professional Java practices:
mainacts as the entry point- Business logic lives in methods
- Methods are reusable and testable
- Code is readable and maintainable
This structure prepares you for:
- Larger Java projects
- Team-based development
- Frameworks like Spring Boot
Before submitting, confirm:
- Program compiles and runs
- Uses
Scannerfor input - Uses
Math.round() - Contains multiple custom methods
- Methods are called from
main - Output is clearly labeled
- Work is pushed to your own branch