Skip to content

Project · Kotlin and Android App Development

Project: a kirana store's stock and GST bill

Projectbeginner· about 4 hours· 6 steps

The brief

Sharma Kirana Store wants a small billing program before it pays for an app. You write it in Kotlin: a stock list with data classes, safe lookups by item code, a cart that refuses unknown items and too-large quantities, GST split into CGST and SGST, a reorder list and a final bill rounded for UPI.

Why it matters

Billing is the heart of every retail, pharmacy and restaurant app in India. The same pieces (items, a cart, GST by rate, stock updates) appear in point-of-sale apps, in the backend of e-commerce sites and in Android apps for shopkeepers. Keeping money in paise is how real payment code avoids rounding errors.

Skills you practise

  • data classes and copy
  • extension functions
  • null safety with ?. ?: and smart casts
  • when without an argument
  • groupBy, sumOf, associate, filter, sortedBy, joinToString
  • integer money in paise

You need

  • IntelliJ IDEA Community Edition (free) with a new Kotlin project, or the Kotlin Playground (play.kotlinlang.org)

What you will have at the end

Kirana.kt: a Kotlin console program that prints the stock list, a validated cart, GST split into CGST and SGST, a reorder list and a final bill rounded for UPI.

How it is marked (rubric, 100 points)
Correct moneyEvery amount matches the sample to the paisa: subtotal Rs 1169.00, GST Rs 90.82, total Rs 1259.82, pay Rs 1260.35
Safe with bad inputUnknown codes, lower-case codes and too-large quantities are handled without a crash and without !!.25
Good KotlinData classes with copy, an extension for rupees, when for decisions and collection operations instead of manual loops where they fit.25
Readable and explainedClear names, comments only where the reason is not obvious, and you can explain why money is kept in paise.15

0/6 steps done

Step 1 of 6

The stock list in rupees

The program prints all six items with their price in rupees and paise, and a stock value of Rs 12476.00.

Money is stored in paise as a Long, because Double cannot hold amounts like 0.10 exactly and errors build up over many bills. Only when printing do you turn paise into rupees: rupees are paise / 100, and the paise part is paise % 100, padded to two digits so 5 paise prints as 05.

Write the extension function Long.rupees(), print one line per item, then the stock value: the sum of price x stock for every item.

Run this on your machine, then paste the output below
$ Run Kirana.kt and paste the output

Also check yourself

Your notes: Kirana.kt

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