Question

In: Computer Science

Please write a program in c# that meets the following specifications.   Dominion Gas Corporation would like...

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:

  • Instance variable for account number and its property
  • Instance variable customer name and its property
  • Instance variable balance and its property
  • Instance variable to store mcf
  • Instance variable to store the rate of the account ($8.99 for residential, $11.99 for commercial)
  • Instance variable to store usage charge for consumption of gas (mcf * rate)
  • Instance variable to store municipal charge (2% of usage charge)
  • Instance variable to store excise tax (5% of usage charge)

Constructor

  • A constructor that accepts the account number and the customer name and uses those two values to initialize the appropriate instance variables (account number, customer name)

Methods

  • A method that calculates the bill.
    • This method asks the user for the type of account (residential/commercial) for which the bill is to be calculated.
    • It also asks the user for the MCF used.
    • Based on these two pieces of information, it calculates the usage charge, municipal charge, excise tax and balance. It stores all these figures in their appropriate instance variables.
  • A method that displays the bill.
    • This method simply prints out all the information about the bill such as the customer name, account number, the usage charge, municipal charge, excise tax and balance (see figures for samples of output)

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.

Solutions

Expert Solution

//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


Related Solutions

Design c++ program so that it correctly meets the program specifications given below.   Specifications: Create a...
Design c++ program so that it correctly meets the program specifications given below.   Specifications: Create a menu-driven program that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- square 2 -- circle 3 -- right triangle 4 -- quit If the user selects choice 1, the program should find the area of a square. If the user selects choice 2, the program should find the area of a circle. If the...
Write a C program that meets the following requirements. Uses a while loop to display the...
Write a C program that meets the following requirements. Uses a while loop to display the first 10 natural numbers (on one row, with a tab separating each number) Uses a while loop to find the sum of the second set of 10 natural numbers. Reads a user entry and displays all the natural numbers up to the user entry (on a column list with a new line separating each number). Finds and displays the sum of all natural numbers...
Program Specifications: PART ONE: The client would like a program that inputs a user's first and...
Program Specifications: PART ONE: The client would like a program that inputs a user's first and last name. The program will also input the user's height and weight. The program will output the following for the input data. (assuming the input was Dennis, Hunchuck, 6.0, 220.0) You can assume that the user runs 1 mile per day. The user loses 1/2 pound for each day he or she runs. You can ask the user how many days he or she...
Create a Java application that meets the following specifications. Write whatever public and private methods are...
Create a Java application that meets the following specifications. Write whatever public and private methods are necessary. Put all of these classes in a package called persistence1. Student has a String name, a double GPA, and a reasonable equals() method. Course has a String name, an ArrayList of Students, and a reasonable equals() method. It will also need a method to add a Student. StudentPersister uses binary file I/O to save and retrieve Students and Lists of Students. CoursePersister does...
IN JAVACreate a Java application that meets the following specifications. Write whatever public and private methods...
IN JAVACreate a Java application that meets the following specifications. Write whatever public and private methods are necessary. Put all of these classes in a package called persistence1. Student has a String name, a double GPA, and a reasonable equals() method. Course has a String name, an ArrayList of Students, and a reasonable equals() method. It will also need a method to add a Student. StudentPersister uses binary file I/O to save and retrieve Students and Lists of Students. CoursePersister...
IN JAVACreate a Java application that meets the following specifications. Write whatever public and private methods...
IN JAVACreate a Java application that meets the following specifications. Write whatever public and private methods are necessary. Put all of these classes in a package called persistence1. Student has a String name, a double GPA, and a reasonable equals() method. Course has a String name, an ArrayList of Students, and a reasonable equals() method. It will also need a method to add a Student. StudentPersister uses binary file I/O to save and retrieve Students and Lists of Students. CoursePersister...
Create a Java application that meets the following specifications. Write whatever public and private methods are...
Create a Java application that meets the following specifications. Write whatever public and private methods are necessary. Put all of these classes in a package called persistence1. The student has a String name, a double GPA, and a reasonable equals() method. The course has a String name, an ArrayList of Students, and a reasonable equals() method. It will also need a method to add a Student. StudentPersister uses the binary file I/O to save and retrieve Students and Lists of...
Create a Java application that meets the following specifications. Write whatever public and private methods are...
Create a Java application that meets the following specifications. Write whatever public and private methods are necessary. Put all of these classes in a package called persistence1. The student has a String name, a double GPA, and a reasonable equals() method. The course has a String name, an ArrayList of Students, and a reasonable equals() method. It will also need a method to add a Student. StudentPersister uses the binary file I/O to save and retrieve Students and Lists of...
Please read the Specifications carefully. Also do not use any C library. Program Specifications Assuming that...
Please read the Specifications carefully. Also do not use any C library. Program Specifications Assuming that all input strings are non-empty (having length of at least 1) and shorter than MAX_LENGTH, implement the following string functions: • strgLen( s ): return the length of string s. • strgCopy( s, d ): copy the content of string s (source) to d (destination). • strgChangeCase( s ): for each character in the string, if it is an alphabet, reverse the case of...
Directions: You are to write a C++ program that meets the instruction requirements below. Deliverables: ·...
Directions: You are to write a C++ program that meets the instruction requirements below. Deliverables: · Your C++ source code file. (The file with the .CPP extension).No other files will be accepted. A screenshot of your program running. Program Instructions: Consider the following incomplete C++ program: #include int main() { … } 1. Write a statement that includes the header files fstream, string, and iomanip in this program. 2. Write statements that declare inFile to be an ifstream variable and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT