Question

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

Account.cs Account class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dominion_Gas_Corporation
{
class Account
{
private int account_number;
private string name;
private double balance;
private double mcf, rate, charge, municipal_charge, excise_tax;

public string Name
{
get { return name; }
set { name = value; }
}
public int AccountNumber
{
get { return account_number; }
set { account_number = value; }
}
public double Balance
{
get { return balance; }
set { balance = value; }
}

public Account(int num, string name)
{
AccountNumber = num;
Name = name;
}
public void CalculateCost()
{
int type;
Console.WriteLine("\n1) Residential\n2) Commercial");
Console.Write("Enter your account type: ");
type = Convert.ToInt16(Console.ReadLine());
if (type == 1)
rate = 8.99;
if (type == 2)
rate = 11.99;
Console.Write("Enter the amount of gas consumed during month in MCF: ");
mcf = Convert.ToDouble(Console.ReadLine());
charge = rate * mcf;

municipal_charge = charge * 0.02;
excise_tax = charge * 0.02;
balance = charge + municipal_charge + excise_tax;
}
public void printInfo()
{
Console.WriteLine("\n\nCustomer Name: " + name);
Console.WriteLine("Account Number: " + account_number);
Console.WriteLine("Usage Charge: $" + charge);
Console.WriteLine("Municipal Charge: $" + municipal_charge);
Console.WriteLine("Excise tax: $" + excise_tax);
Console.WriteLine("Balance: $" + balance);
}
}
}

AccounTest.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dominion_Gas_Corporation
{
class AccountTest
{
static void Main(string[] args)
{
String name;
int number;
Console.Write("Enter youe name: ");
name = Console.ReadLine();
Console.Write("Enter your account number: ");
number = Convert.ToInt32(Console.ReadLine());

Account obj1 = new Account(number, name);
obj1.CalculateCost();
obj1.printInfo();
}
}
}
output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
Please write a program in c# that meets the following specifications.   Dominion Gas Corporation would like...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super...

    Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...

  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • Please Write the following program in c# You are to write an application which will create...

    Please Write the following program in c# You are to write an application which will create a company, add agents (their name, ID, and weekly sales) to that company, and printout the details of all agents in the company. The application will contain three classes: Agent.cs, Company.cs, and CompanyTest.cs (this class is already provided). Flow of the application: The CompanyTest class creates an object of the Company class and reserves space for five agents. At this point if you call...

  • Download BankAccount.java and BankAccountTester.java starting files and drag and drop them into your eclipse project. The...

    Download BankAccount.java and BankAccountTester.java starting files and drag and drop them into your eclipse project. The BankAccount class declaration in file BankAccount.java is the blueprint of a BankAccount object. Check out the design of a BankAccount class. 1. In BankAccount.java class, all of the method stubs ( methods with a header but empty bodies ) are present to help you get started. Your task is to complete the method bodies. All comments in red in the diagram above indicates what...

  • Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Cr...

    Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Create a class called Course. It will not have a main method; it is a business class. Put in your documentation comments at the top. Be sure to include your name. Course must have the following instance variables named as shown in the table: Variable name Description crn A unique number given each semester to a section (stands for Course Registration Number) subject A...

  • This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description:...

    This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...

  • This is a C++ program Instructions Design a class named PersonData with the following member variables...

    This is a C++ program Instructions Design a class named PersonData with the following member variables declared as strings: lastName firstName address city state zip phone Create 3 constructors; a default constructor, a constructor that accepts the first and last name member variables, and a constructor that accepts all member variables. Write the appropriate accessor/getter and mutator/setter functions for these member variables. Create a method within this class called getFullName() that returns the person's first and last names as a...

  • Write the Java code for the class WordCruncher. Include the following members:

    **IN JAVAAssignment 10.1 [95 points]The WordCruncher classWrite the Java code for the class WordCruncher. Include the following members:A default constructor that sets the instance variable 'word' to the string "default".A parameterized constructor that accepts one String object as a parameter and stores it in the instance variable. The String must consist only of letters: no whitespace, digits, or punctuation. If the String parameter does not consist only of letters, set the instance variable to "default" instead. (This restriction will make...

  • Hey all, if you could create a java program following these guidelines that would be much...

    Hey all, if you could create a java program following these guidelines that would be much appreciated. helpful comments in the program would be appreciated :) The idea of this program is as followes : A password must meet special requirements, for instance , it has to be of specific length, contains at least 2 capital letters , 2 lowercase letters, 2 symbols and 2 digits. A customer is hiring you to create a class that can be utilized for...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT