Skip to content

Project · Java Programming (Core to Spring Boot)

Project: a kirana shop sales report

Projectintermediate· about 6 hours· 6 steps

The brief

A kirana shop's billing software exports each week's sales as a CSV file, with the odd bad line typed by hand. You build a small Java program in the package com.kirana that reads the file, skips bad lines with a clear reason, totals sales per item, finds the top sellers, works out GST per category with streams, and writes a report file for the owner and the accountant.

Why it matters

Reading a file of business data, rejecting bad rows without crashing, summarising with maps and streams and writing a report is the everyday work of Java developers in retail, banking and logistics. It is also what most take-home assignments for Java roles look like.

Skills you practise

  • packages and javac -d
  • interfaces with default methods
  • enums with fields
  • records implementing an interface
  • checked custom exceptions
  • Map.merge and TreeMap
  • Comparator chains
  • Collectors.groupingBy
  • Files.readAllLines and Files.write

You need

  • JDK 21 (Eclipse Temurin from adoptium.net or Oracle JDK; JDK 17 or any newer version also works)
  • A text editor or IDE (VS Code with the Extension Pack for Java, or IntelliJ IDEA Community Edition) and a terminal
  • A project folder with src/com/kirana/ for the .java files and sales.csv next to src (not inside it)

What you will have at the end

The com.kirana package (six classes), sales.csv and the generated report.txt, with a README saying how to compile and run it and what each class does.

How it is marked (rubric, 100 points)
Correct numbersEvery check passes: both bad lines skipped with the right line numbers, rice merged to 3200, the right top 3, GST 247.75 and 243.00, gross 7675.75.40
Good use of the languageAn interface with a default method, an enum with fields, records, a checked exception with a cause, merge and groupingBy used where they fit.25
RobustnessNo bad line can crash the report; the file is replaced, not appended to.15
Readable code and READMESmall focused classes in one package, clear names, and a README a new developer could follow.20

0/6 steps done

Step 1 of 6

Model a sale

A Sale record implements Taxable, and 3 bags of rice at Rs 640 under STAPLES (5%) give GST on rice: 96.00.

Put the .java files in src/com/kirana/ (each starts with package com.kirana;). javac -d out compiles them into out/com/kirana/, and java -cp out com.kirana.Report runs the class by its full name. Taxable is an interface: amount() and gstRatePercent() are abstract, and gst() is a default method built from them. Category is an enum whose constants carry their GST rate (example rates). Sale is a record that implements Taxable.

project/
├── sales.csv
├── src/com/kirana/Report.java (and the others)
└── out/            ← made by javac -d out
Run both commands from the project folder.
Run this on your machine, then paste the output below
$ javac -d out src/com/kirana/*.java java -cp out com.kirana.Report

Also check yourself

Your notes: Taxable.java, Category.java, Sale.java, InvalidSaleException.java, SaleParser.java, Report.java

Write down each command you ran. It goes into your project summary.