In: Computer Science
Please write a program in c# that meets the following specifications.
Dominion Gas Corporation would like you to develop an application that helps them calculate the gas consumption bill of their customers. The application would first ask for the customer account number, the customer name and the type of account (residential or commercial). Then the application asks for the gas consumed during the past month by the customer in MCF (the unit used to indicate the amount of gas consumed). After gathering all this information the application calculates the bill based on the type of account (residential or commercial) and prints out the bill.
Technical Specifications:
The application will have two classes: Account and AccountTest
The Account class will have the following elements in it:
INSTANCE VARIABLES:
Constructor
Methods
The AccountTest class will have the following elements in it
the main method performs the following actions
asks for the account number, reads it in and stores it in a variable
Asks for the customer name, reads it in and stores it in a variable
uses these two pieces of information to create an object using the Account class's constructor
Calls the method that calculates the bill for the object created
calls the method that displays the bill for the object created.
//C# Code
using System;
class AccountTest
{
static void Main(string[] args)
{
Console.Write("Enter customer name: ");
string name = Console.ReadLine();
Console.Write("Enter account Number: ");
int accNum = int.Parse(Console.ReadLine());
Account account = new Account(accNum,name);
account.calculateBill();
account.display();
//pause
Console.ReadLine();
}
}
class Account
{
const double MUNICIPAL_CHARGE = 0.02;//2%
const double EXCISE_TAX = 0.05;//5%
private int accountNumber;
private string customerName;
private double balance;
private double mcf;//gas consumed
private double rateForResidential = 8.99;
private double rateForCommercial = 11.99;
private double usageCharges;
private double municpal_charge;
private double excise_tax ;
//Constructor
public Account(int accountNumber,string customerName)
{
this.accountNumber = accountNumber;
this.customerName = customerName;
}
public void calculateBill()
{
Console.Write("Enter type of account: (residential/commercial)
");
string type = Console.ReadLine();
if(type == "residential")
{
Console.Write("MCF used: ");
mcf = Double.Parse(Console.ReadLine());
usageCharges = mcf * rateForResidential;
municpal_charge = usageCharges * MUNICIPAL_CHARGE;
excise_tax = usageCharges * EXCISE_TAX;
balance = (usageCharges + municpal_charge + excise_tax);
}
else if(type == "commercial")
{
Console.Write("MCF used: ");
mcf = Double.Parse(Console.ReadLine());
usageCharges = mcf * rateForCommercial;
municpal_charge = usageCharges * MUNICIPAL_CHARGE;
excise_tax = usageCharges * EXCISE_TAX;
balance = (usageCharges +municpal_charge + excise_tax);
}
else
{
Console.WriteLine("Unknown account type!");
}
}
public void display()
{
Console.WriteLine("Customer Name: " + customerName + "\nAccount
Number: " + accountNumber + "\nUsage Charge: " +
usageCharges.ToString("C")
+ "\nMunipal Charge: " + municpal_charge.ToString("C") + "\nExcise
tax: " + excise_tax.ToString("C") + "\nBalance: " +
balance.ToString("C"));
}
}
//Output
//If you need any help regarding this solution .......... please leave a comment ........ thanks