Skip to content

Project · Rust Programming

Project: a kirana bill calculator

Projectbeginner· about 4 hours· 7 steps

The brief

Write a command-line bill calculator for Shree Ganesh Kirana Stores. It prints each item line, the subtotal, CGST and SGST (example GST rates), and the grand total; asks for the customer's name and the cash paid; and prints the change. Money is kept in whole paise, the bill is built in one String passed by &mut, and the finished tool is a fast release build.

Why it matters

Billing is the first software almost every small shop in India buys: lakhs of kirana stores, medical shops and restaurants run a billing tool at the counter. Getting the money exactly right (no floating-point paise), splitting GST into CGST and SGST, and not crashing on a typo are the basics such tools must get right.

Skills you practise

  • constants and arrays of tuples
  • functions with typed parameters
  • for loops and running totals
  • integer paise and {:02} formatting
  • format!, String and &str
  • &mut String parameters
  • reading input with a retry loop
  • cargo build --release

You need

  • Rust stable installed with rustup
  • A terminal: bash, Git Bash or PowerShell

What you will have at the end

A kirana_bill cargo project and its release program: item lines, CGST and SGST, grand total, the customer's name and correct change, with no warnings.

How it is marked (rubric, 100 points)
Correct moneyEvery amount matches to the paisa: lines, subtotal, CGST, SGST, grand total and change.40
Ownership-correct stringsNames returned as owned String, the bill built through &mut String and &str parameters, no needless clone().25
Robust inputTypos are reported and asked again; trimmed input; paying too little is handled.20
Clean, readable codeSmall functions, constants for fixed values, no warnings in the release build.15

0/7 steps done

Step 1 of 7

Start the project and print the header

cargo run prints the shop name and "Bill No. 101".

Create the project with cargo new kirana_bill and copy the starter into src/main.rs. The shop name and bill number are constants, so they are written once at the top and can never change by accident. Print the two header lines from main. The starter compiles already, with warnings for the functions you have not used yet; they disappear as you fill them in.

Run this on your machine, then paste the output below
$ cargo run
Your notes: src/main.rs

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