Ad Code

✨🎆 Codex 1.0 PLACEMENT READY PROGRAM! 🎆✨

Get 75% Discount Early bird offer CLICK to JOIN CodeX 1.0 click

Assignment of C#:-

Assignment of C#:-

1)  WAP to reverse three-digit number without using Loop

2)  WAP  to calculate electricity bill where unit price and total consumption will be entered by the user.

3)  WAP to create a salary calculator where basic, ta, da, comm,pf, and noofleave will be entered by the users.



using System;

class SalaryCalc
{
    public static void Main()
    {
          float basic=12000,ta=200,da=200,comm=300,pf=500,nl=2,asal=200;
          float tsal,gsal;
          gsal=basic+ta+da+comm;
          Console.WriteLine("Gross Salary Is {0}",gsal);
          tsal=gsal-(gsal/30)*nl-asal-pf;
          Console.WriteLine("Total Salary Is {0}",tsal);

    }

}
4)  WAP to calculate Area of Circle and Area of Triangle.  


Post a Comment

9 Comments

  1. using System;
    class reverse
    {
    public static void Main()
    {
    int a,b,c,d,rev;
    Console.WriteLine("enter three digit number");
    a=int.Parse(Console.ReadLine());
    b=a%10;
    c=(a/10)%10;
    d=(a/10)/10;
    rev=b*100+c*10+d;

    Console.WriteLine("result is{0}",+rev);
    }
    }

    ReplyDelete
  2. static void Main(string[] args)
    {
    float a=3, b=6, c=7;
    float semipermiter = (a + b + c) / 2;
    float area = ((float)Math.Sqrt(semipermiter * (semipermiter-a) * (semipermiter-b) *( semipermiter-c)));
    Console.WriteLine("area of triangle is :"+area);
    }

    ReplyDelete
  3. static void Main(string[] args)
    {
    int price; int totalunit; int calcunit;
    Console.WriteLine("ENTER PRICE PER UNIT :");
    price = int.Parse(Console.ReadLine());
    Console.WriteLine("ENTER TOTAL UNIT USED :");
    totalunit = int.Parse(Console.ReadLine());
    calcunit = price * totalunit;
    Console.WriteLine("TOTAL COST CALCULATE :" + calcunit);
    Console.ReadKey();
    }

    ReplyDelete
  4. void salaryCalculator()
    {
    Double bs, ta, da, comm, nol, pf;
    Console.WriteLine("Salary Calulator");
    Console.WriteLine("Enter Basic Salary");
    bs = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter Traveling allownce (TA)");
    ta = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter Dearness Allownces (DA)");
    da = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter commession (Comm)");
    comm = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter Provident Found");
    pf = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter No of leave");
    nol = Convert.ToDouble(Console.ReadLine());
    double gross = bs + ta + da + comm;
    Console.WriteLine("Gross Salary {0}", gross);
    double netsalary = gross - (bs / 30) * nol - pf;
    Console.WriteLine("Net Salary {0}",netsalary);
    }

    ReplyDelete
  5. //WAP Reverse 3 digit number without using loop
    namespace Task
    {
    internal class Reverse
    {
    public static void Main()
    {
    Console.WriteLine("Enter number = ");
    int num = int.Parse(Console.ReadLine());
    int a,b,c,rev;
    a=num / 100;
    b = num % 100;
    b = b / 10;
    c = num % 10;
    rev = c* 100 + b * 10 + a;
    Console.WriteLine(" Reverse ={0}",rev);
    }
    }
    }

    ReplyDelete
  6. //WAP Reverse 3 digit number without using loop
    namespace Task
    {
    internal class Reverse
    {
    public static void Main()
    {
    Console.WriteLine("Enter number = ");
    int num = int.Parse(Console.ReadLine());
    int a,b,c,rev;
    a=num / 100;
    b = num % 100;
    b = b / 10;
    c = num % 10;
    rev = c* 100 + b * 10 + a;

    Console.WriteLine(" Reverse ={0}",rev);
    }
    }
    }

    ReplyDelete
  7. internal class Reverse
    {
    public static void Main()
    {
    Console.WriteLine("Enter number = ");
    int num = int.Parse(Console.ReadLine());
    int a,b,c,rev;
    a=num / 100;
    b = num % 100;
    b = b / 10;
    c = num % 10;
    rev = c* 100 + b * 10 + a;
    Console.WriteLine(" Reverse ={0}",rev);
    }
    }
    }

    ReplyDelete
  8. Muhammad Rizwan JamaliDecember 18, 2025 at 12:23 PM


    2) WAP to calculate electricity bill where unit price and total consumption will be entered by the user.
    -----------------------------------------------------------------------------------------------------------------------------------------------------
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;

    namespace HelloWorld
    {
    public class Program
    {
    public static void Main(string[] args)
    {
    KElectricBill obj = new KElectricBill();
    obj.billCalculate(50);
    Console.WriteLine("-----------------------");
    obj.billCalculate(51);
    obj.billCalculate(100);
    Console.WriteLine("-----------------------");
    obj.billCalculate(200);
    obj.billCalculate(201);
    }
    }
    }


    class KElectricBill{
    internal void billCalculate(int units){
    /*

    0-50 units: ₨ 15 per unit
    51-100 units: ₨ 18 per unit
    101-200 units: ₨ 22 per unit
    201+ units: ₨ 25 per unit

    */
    float bill;

    if(units > 0 && units <= 50) {
    // SLAB 1
    bill = units * 15;
    Console.WriteLine("{0} units bill is {1}", units, bill);

    } else if (units > 50 && units <= 100) {
    // SLAB 2
    bill = (50 * 15) + (units - 50) * 18;
    Console.WriteLine("{0} units bill is {1}", units, bill);

    } else if (units > 100 && units <= 200) {
    // SLAB 3
    bill = (50 * 15) + (50 * 18) + (units - 100) * 22;
    Console.WriteLine("{0} units bill is {1}", units, bill);

    } else if (units > 200){
    // SLAB 4
    bill = (50 * 15) + (50 * 18) + (100 * 22) + (units - 200) * 25;
    Console.WriteLine("{0} units bill is {1}", units, bill);
    }


    }
    }
    --------------------------------------------------------------------------------------------------------------------
    Output:

    50 units bill is 750
    ----------------------------------
    51 units bill is 768
    100 units bill is 1650
    ----------------------------------
    200 units bill is 3850
    201 units bill is 3875

    ReplyDelete
  9. WAP to reverse three-digit number without using Loop:: int num;
    int a, b, c;
    string reverse;
    Console.WriteLine("enter digit");
    num = Convert.ToInt32(Console.ReadLine());
    a = num % 10;
    b = (num / 10) % 10;
    c = (num / 100) % 10;
    reverse = a + "" + b + "" + "" + c;
    Console.WriteLine(reverse);

    ReplyDelete

POST Answer of Questions and ASK to Doubt