Skip to content

Lab · C# and .NET

Lab: housing society maintenance

Labbeginner· about 1.5 hours· 5 steps

The brief

The treasurer of Green Park Society in Pune works out every flat's monthly maintenance by hand. You write small methods for the maintenance, parking and late fee rules, combine them into a monthly bill, loop over a quarter, and look up a flat's area with an out parameter.

Why it matters

Society management apps (and the Excel sheets they replace) are built from exactly these rules: rates per square foot, fixed charges and penalties with cut-off days. Splitting each rule into its own method is how real billing code stays easy to check and to change when the committee changes a rate.

Skills you practise

  • static methods and return
  • switch expressions
  • if / else if
  • boundary values
  • for loops
  • optional and out parameters

You need

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

What you will have at the end

The SocietyDues console project with Maintenance, Parking, LateFee, MonthlyBill and TryGetArea methods and a quarter's statement for flat B-204.

How it is marked (rubric, 100 points)
Correct rulesEvery check passes, including the 15/16-day edge and month 3 of the quarter.40
Good methodsOne rule per method, each returning a value; MonthlyBill only combines them.30
Right C# featuresswitch expressions with a _ arm, optional parameters with defaults, and the Try pattern with out.20
Readable codePascalCase method names, camelCase variables and no repeated rate numbers.10

0/5 steps done

Step 1 of 5

Maintenance per square foot

Maintenance(sqft) returns Rs 2.50 per square foot: 2125.00 for 850 sq ft and 3000.00 for 1200 sq ft.

Create the project with dotnet new console -o SocietyDues and replace Program.cs with this lab's starter. The calls are already written at the top; you only fill in the method bodies, one per step. A method returns its answer with return, so the caller can print it or add it up. Multiply the int area by the decimal rate 2.50m: the result is a decimal.

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.