0% found this document useful (0 votes)
8 views7 pages

1) Code: Using System Class Oddoreven (Static Void Main (Console - Write ("Enter A Number: ") Int Number Convert - Toint32 (Console - Readline )

The document contains three C# programs: the first checks if a number is odd or even, the second determines if a year is a leap year, and the third calculates an electricity bill based on usage. Each program prompts the user for input and displays the result accordingly. The code snippets include basic conditional statements and calculations.

Uploaded by

Sarathi M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

1) Code: Using System Class Oddoreven (Static Void Main (Console - Write ("Enter A Number: ") Int Number Convert - Toint32 (Console - Readline )

The document contains three C# programs: the first checks if a number is odd or even, the second determines if a year is a leap year, and the third calculates an electricity bill based on usage. Each program prompts the user for input and displays the result accordingly. The code snippets include basic conditional statements and calculations.

Uploaded by

Sarathi M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1)

Code:

using System;

Class oddoreven

Static void Main()

Console.Write(“Enter a number: “);

Int number = Convert.ToInt32(Console.ReadLine());

String result = (number % 2 == 0) ? “Even” : “Odd”;

Console.WriteLine(result);

}
Output:
2)

Code:

using System;

Class LeapYearCheck

Static void Main()

Console.Write(“Enter a year: “);

Int year = Convert.ToInt32(Console.ReadLine());

Bool isLeap = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);

Console.WriteLine(isLeap ? “Leap Year” : “Not a Leap Year”);

}
Output:
3)

Code:

using System;

Class ElectricityBill

Static void Main()

Console.Write(“Enter electricity units: “);

Int units = Convert.ToInt32(Console.ReadLine());

Double billAmount = 0;

Int extraCharge = 0;

If (units <= 100)

billAmount = 0;

extraCharge = 0;

Else if (units <= 250)

billAmount = units * 0.80;

extraCharge = 25;

Else if (units <= 450)

{
billAmount = units * 1.50;

extraCharge = 75;

Else

billAmount = units * 2.00;

extraCharge = 100;

Double total = billAmount + extraCharge;

Console.WriteLine(“Normal Charges: Rs. “ + billAmount);

Console.WriteLine(“Extra Charges: Rs. “ + extraCharge);

Console.WriteLine(“Total Bill: Rs. “ + total);

}
Output:

You might also like