Bill Splitter Console App
Part of the Java Roadmap
In short
Your first real project: a dinner bill splitter for friends. It uses everything from this phase, and it is exactly the kind of small, finished program that shows you can turn concepts into something useful.
A small console app that reads a restaurant bill in rupees, the tip percentage and the number of friends, then prints each person's share neatly formatted. It practises variables, operators, casting, strings and Scanner input.

Think of it like this
Settling up after dinner
Five friends finish dinner at a Koramangala café. Someone reads the bill, someone suggests a 10% tip, and someone does the maths on their phone. Your app is that friend: it takes the bill, the tip and the headcount, and says exactly what each person owes.
The big ideas
What you need to know
Input
Scanner with hasNextDouble and hasNextInt for safe reading.
Arithmetic
Use 100.0, not 100, so the tip is calculated in double.
Formatting
printf("%.2f") shows exactly two decimal places.
Stretch goals
Uneven splits, a GST line, or rounding each share up to the nearest rupee.
How it works
Building the splitter
- 1
Read inputs
Bill amount (double), tip percent (int) and number of people (int), using one Scanner.
- 2
Validate
Reject a bill of zero or less and fewer than one person, asking again until the input is valid.
- 3
Calculate
tip = bill * tipPercent / 100.0; total = bill + tip; share = total / people.
- 4
Round to paise
Use Math.round(share * 100) / 100.0 so each share is a clean rupee-and-paise amount.
- 5
Print a summary
Use printf or a StringBuilder for a neat aligned receipt.
See it in code
Walk through the code
1import java.util.Scanner;2 3public class BillSplitter {4 5 static double readPositive(Scanner sc, String prompt) {6 double value;7 do {8 System.out.print(prompt);9 while (!sc.hasNextDouble()) {10 sc.next();11 System.out.print("Numbers only. " + prompt);12 }13 value = sc.nextDouble();14 } while (value <= 0);15 return value;16 }17 18 public static void main(String[] args) {19 Scanner sc = new Scanner(System.in);20 double bill = readPositive(sc, "Bill amount (₹): ");21 int tipPercent = (int) readPositive(sc, "Tip %: ");22 int people = (int) readPositive(sc, "Number of people: ");23 24 double tip = bill * tipPercent / 100.0;25 double total = bill + tip;26 double share = Math.round(total / people * 100) / 100.0;27 28 System.out.printf("Bill: ₹%.2f%n", bill);29 System.out.printf("Tip (%d%%): ₹%.2f%n", tipPercent, tip);30 System.out.printf("Total: ₹%.2f%n", total);31 System.out.printf("Each of %d pays: ₹%.2f%n", people, share);32 }33}1/4A reusable helper that keeps asking until it gets a positive number.
A complete splitter with input validation, a helper method and formatted output.
Save yourself the pain
Common mistakes
Oops
tip = bill * tipPercent / 100; with an int bill.
Do this instead
Integer division loses the paise. Keep bill as double and divide by 100.0.
Oops
Letting the app crash with a divide-by-zero style result when people is 0.
Do this instead
Validate input. With doubles you get Infinity instead of a crash, which is even sneakier.
Your mission
Ship the splitter
Quick check
Which line correctly prints 12.5 as "₹12.50"?
Go deeper
- 1Read the bill, tip and number of people with Scanner and validate each value.
- 2Print the share rounded to two decimal places with String.format or printf.
- 3Add an option for unequal splits where each person enters what they ordered.
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.