Skip to content

Lab · C# and .NET

Lab: clean up a UPI statement

Labbeginner· about 2 hours· 5 steps

The brief

Asha exported her October UPI payments from her bank app, and the payee names are messy: extra spaces, capitals, and one payment with no name. You split the lines into arrays, clean the names, total the spending per payee, find the last payment, and print a neat statement with StringBuilder.

Why it matters

Banks, fintech apps and accountants import messy exported data every day. Cleaning text, matching names without caring about case, and handling missing values without crashing are core tasks in any data-import or reporting job.

Skills you practise

  • arrays and indexes
  • Split and decimal.Parse
  • Trim, ToLower and ranges
  • string.IsNullOrWhiteSpace
  • StringComparison.OrdinalIgnoreCase
  • null and ??
  • StringBuilder and alignment

You need

  • .NET 8 SDK or newer
  • A console project made with dotnet new console -o UpiStatement (copy this lab's Program.cs into it)

What you will have at the end

The UpiStatement console project: it parses a UPI export, cleans payee names, totals spending per payee without caring about case, handles a missing name and a missing payee, and prints an aligned statement.

How it is marked (rubric, 100 points)
Correct resultsEvery check passes: 2390.50 in total, 848.00 at Swiggy, 05-10-2026 as the last Swiggy date.40
Safe with missing dataThe blank payee and the unknown payee never crash the program; null is handled with ??.25
Good string handlingResults of Trim and ToLower are stored; comparisons ignore case with OrdinalIgnoreCase.20
Clean outputThe table lines up, and StringBuilder.ToString() is called once.15

0/5 steps done

Step 1 of 5

Split the lines and add up the amounts

The program prints 5 payments, a total of Rs 2390.50 and a highest payment of Rs 1250.50.

Each line holds three values separated by commas. line.Split(',') gives a string[] of the parts, so parts[2] is the amount, which decimal.Parse turns into a number. Store the amounts in a decimal[] of the same length as statement, then loop to find the total and the highest. Loop with i < statement.Length: indexes go from 0 to Length - 1, and stopping one early silently drops the last payment.

Run this on your machine, then paste the output below
$ dotnet run
Your notes: Program.cs

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