Class Diagram :-
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
//Design
a class to accept ElectricBill customer details and calculate and print
Electricity Bill
namespace CAClasses
{
class ClsEBill
{
int CNumber,
PrvRead, PressRead, Units;
double
Price;
public
void GetCData()
{
Console.WriteLine("Enter Customer Details of Electric Bill");
Console.WriteLine("Enter Customer Number");
this.CNumber
= Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Previous Reading");
this.PrvRead
= Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Present Reading");
this.PressRead
= Convert.ToInt32(Console.ReadLine());
}
public
void Calculate()
{
this.Units
= this.PressRead - this.PrvRead;
this.Price
= 4* this.Units;
}
public
void DisplayCData()
{
Console.WriteLine("Customer number is " + this.CNumber);
Console.WriteLine("PrvRead is " + this.PrvRead);
Console.WriteLine("Presents Reading is " + this.PressRead);
Console.WriteLine("Units are " + this.Units);
Console.WriteLine("price is " + this.Price);
}
}
class ClsExample3
{
static
void Main()
{
ClsEBill
Obj1 = new ClsEBill();
Obj1.GetCData();
Obj1.Calculate();
Obj1.DisplayCData();
Console.ReadLine();
}
}
}
|
Output :-
No comments:
Post a Comment