Question

C#

3. Write a program to calculate and print the Electricity bill of a given customer. Read the units consumed by the user from

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

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

public class ElectricityBillCalculation
{
public static void Main(string[] args)
{
  
int units = Convert.ToInt16(Console.ReadLine()); // Reading the units consumed from the console
double a,b,c,d,e; // Initialising variables
int p,q,r,s; // Initialising variables
Console.WriteLine("Enter the units consumed by the customer :{0}", units); // Printing units consumed by the customer
if (units <= 200) // If condition to check if units consumed are less than or equal to 200
{ // Enters if condition is satisfied
a = (units * 1.5); // Bill calculation using Mul operator
Console.WriteLine("Total amount to pay ={0}", a); // Printing electricity bill to be pais by customer

}
else if (units >= 201 && units <= 400) // If condition to check if units >= 201 and <=400
{ // Enters if condition is satisfied
p = units - 200; // Storing how many units consumed above 200
b = (p * 1.8) + 300; // Bill calculation using Mul operator for units >200 and <=400, adding bill for 400 units
Console.WriteLine("Total amount to pay ={0}", b); // Printing electricity bill to be pais by customer

}
else if (units >= 401 && units <= 600) // If condition to check if units >= 401 and <=600
{ // Enters if condition is satisfied
q = units - 400; // Storing how many units consumed above 400
c = (q * 2.1) + 300 + 360; // Bill calculation using Mul operator for units greater than 400 and adding bill for 400 units
Console.WriteLine("Total amount to pay ={0}", c); // Printing electricity bill to be pais by customer
}
else if (units >= 601 && units <= 800) // If condition to check if units >= 601 and <=800
{ // Enters if condition is satisfied
r = units - 600; // Storing how many units consumed above 600
d = (r * 2.5) + 300 + 360 + 420; // Bill calculation using Mul operator for units greater than 600 and adding bill for 600 units
Console.WriteLine("Total amount to pay ={0}", d); // Printing electricity bill to be pais by customer
}
else if (units > 800) // If condition to check if units >800
{ // Enters if condition is satisfied
s = units - 800; // Storing how many units consumed above 800
e = (s * 2.7) + 300 + 360 + 420 + 500; // Bill calculation using Mul operator for units greater than 800 and adding bill for 800 units
Console.WriteLine("Total amount to pay ={0}", e); // Printing electricity bill to be pais by customer
}

Console.ReadKey();
}
}

main.cs 1. using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 public class Elect

Add a comment
Know the answer?
Add Answer to:
C# 3. Write a program to calculate and print the Electricity bill of a given customer....
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
  • Need help with this please Lab 14 Electricity Bill Worksheet Background knowledge. The power of an...

    Need help with this please Lab 14 Electricity Bill Worksheet Background knowledge. The power of an electrical appliance is measured in watt (W). One watt is a measure of the energy used up in one second. The unit used for calculating power consumption is the kilowatt-hour (kWh). In order to calculate power consumed by an electrical appliance, we first convert the power to kilowatt (kW). For example, 800 W=0.8 kW, 2000 W = 2.0 kW and so on. One unit...

  • The utility department of Brentwood City needs you to write a C++ program that will print...

    The utility department of Brentwood City needs you to write a C++ program that will print out a customer's bill. The program should input the following items from the file named "utility.txt" (which you may copy from the class data share or Blackboard): The customer number (6-digit integer) The number of gallons of water used (floating-point, no more than 999.99) The number of kilowatts of electricity used (integer, no more than 999) The number of cubic feet of natural gas...

  • 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)....

  • computer programming Write a C program that will calculate and print monthly water bills. The total...

    computer programming Write a C program that will calculate and print monthly water bills. The total units consumed per month are derived from subtracting the previous meter readings with the current meter reading. The charges are calculated based on the rates stated in Table 2. The sample output is shown in Figure 16 Tulis aturcara Cyang akan mengira dan mencetak bil air bulanan Jumlah unit yang diguna sebulan dikira dengan menolak bacaan meter sebelum dengan bacaan meter terkinl. Caj dikira...

  • Write a complete C++ program that creates a monthly bill for the text messaging. Your cell...

    Write a complete C++ program that creates a monthly bill for the text messaging. Your cell phone company provides the following three text messaging plans. Package A: Two Thumbs.   For $9.95 per month, 100 text messages are allowed. Additional text messages are 15 cents each. Package B: All Thumbs. For $14.95 per month, 200 text messages are allowed. Additional text messages are 10 cents each. Package C: Lightning Thumbs. For $19.95 per month, unlimited text messaging is provided. State sales...

  • Coding in C++ Write a program using structures to store the following weather information: - Month...

    Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • Question 2 (3 mark): Write a program to implement the class Coffee according to the following...

    Question 2 (3 mark): Write a program to implement the class Coffee according to the following UML diagram and description so that it can display as the output example. Coffee -energy: double -protein: double -fat: double +Coffee +Coffee _energy: double, _protein: double. _fat: double) Coffee(sourceCup: Coffee) -printNutrition Information(): void +main(String[] args): void REQUIREMENTS The program has three constructors: the first one is a default constructor, it initializes the 3 data fields (50.0, 1.5, 1.7) at default; the second initializes the...

  • c++ programming no use of classes use of functions pseudo code with comments Requirement: Provide one...

    c++ programming no use of classes use of functions pseudo code with comments Requirement: Provide one application for a business store that sale 2 models of one proo model FA218 and model FA318. The application first provides the menu to allow users can select one of the following tasks per time and when they finish one task, they can continue the application to select other task from the menu until they choose exit. All the output on the screen and...

  • I can't figure out adjusting journal entries and T acct Transaction List Sept. 1Purchased new office...

    I can't figure out adjusting journal entries and T acct Transaction List Sept. 1Purchased new office furniture of S6,000 by signing a one-year note payable with vendor. The stated interest rate is 10%. 2 Purchased 30 units of the new coffee table books from supplier, Art Image, on account for $14.50 each. Credit terms are 2/10, 1/30. Shipping terms are FOB Destination. Freight charges on this order amount to $35. 3 Was granted allowance from Art Image for 2 defective...

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