Question

In: Computer Science

Part 2: An electric company charges to their customers based on Kilowatt-Hours (Kwh) used. The rules...

Part 2: An electric company charges to their customers based on Kilowatt-Hours (Kwh) used. The rules to compute the charge are: First 100 Kwh, 35 cents per Kwh Each of the next 100 Kwh (up to 200 Kwh), 45 cents per Kwh (the first 100 Kwh used is still charged at 35 cents each) Each of the next 300 Kwh (up to 500 Kwh) 65 cents per Kwh All Kwh over 500, 80 cents per KH Create a C# Form with a textbox to enter Kwh used, a read-only textbox to display the electricity charges, and a button to compute the charges. The Kwh used could be a number with decimals. Requirements: 1. Input validation: Use the KWH textbox validating event to ensure the KWH cannot exceed 2000. Test your program with (1) Kwh=4500, (2) Kwh = 350 2. Turn in the form’s screenshot and the code.

In C# using Visual Studios 2017 Windows form app

Solutions

Expert Solution

C# code

============================================================================================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ElectricityBill
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
int kwh;
float bill=0;
kwh = Convert.ToInt32(KWH.Text);
if(kwh<0 || kwh>2000)
{
textBox1.Text = "KWH can not exceed 2000";
}
else
{
if(kwh<=100)
{
bill = 35 * kwh;
}
else if(kwh <= 200)
{
bill = 35 *100+45*(kwh-100);
}
else if (kwh <= 500)
{
bill = 35 * 100 + 45 *100+65 *(kwh - 200);
}
else if (kwh <= 2000)
{
bill = 35 * 100 + 45 * 100 + 65*300 +80* (kwh - 500);
}
bill = bill / 100;
textBox1.Text = "Bill is: $" + bill.ToString();
}
}
}
}

============================================================================================

Output


Related Solutions

Bradford Electric Illuminating Company is studying the relationship between kilowatt-hours (thousands) used and the number of...
Bradford Electric Illuminating Company is studying the relationship between kilowatt-hours (thousands) used and the number of rooms in a private single-family residence. A random sample of 10 homes yielded the following. Number of Rooms Kilowatt-Hours (thousands) Number of Rooms Kilowatt-Hours (thousands) 12 9 8 6 9 7 10 8 14 10 10 10 6 5 5 4 10 8 7 7 Determine the 0.95 confidence interval, in thousands of kilowatt-hours, for the mean of all six-room homes. (Do not round...
Zoe is thinking of replacing her old refrigerator which uses 1400 kilowatt hours (kWh) of electricity...
Zoe is thinking of replacing her old refrigerator which uses 1400 kilowatt hours (kWh) of electricity per year. A new, more efficient model will cost her $1700 and will use only 600 kWh per year. She pays 10 cents per kWh for her electricity. Assume a time horizon of 4 years (i.e. t=0,1,2,3) and a discount rate of 10 percent. At the end of the three year period, the new fridge is worth $500 in the used fridge market and...
A recent home energy bill indicates that a household used 475 kWh (kilowatt-hour) of electrical energy...
A recent home energy bill indicates that a household used 475 kWh (kilowatt-hour) of electrical energy and 225 therms for gas heating and cooking in a period of 1 month. Given that 1.00 therm is equal to 29.3 kWh, how many milligrams of mass would need to be converted directly to energy each month to meet the energy needs for the home?(in mg)
North Dakota Electric Company estimates its demand trend line (in millions of kilowatt hours) to be: D = 77.0 + 0.45Q,
North Dakota Electric Company estimates its demand trend line (in millions of kilowatt hours) to be: D = 77.0 + 0.45Q,where Q refers to the sequential quarter number and Q=1 for winter of Year 1. In addition, the multiplicative seasonal factors are as follows:QuarterFactor (Index)Winter0.72Spring1.25Summer1.45Fall0.58In year 26 (quarters 101-104), the energy use for each of the quarters beginning with winter is (round your response to one decimal place):QuarterEnergy UseWinterSpringSummerFall
2) The file ‘Energy’ contains the per capita energy consumption (in kilowatt-hours), for each of the...
2) The file ‘Energy’ contains the per capita energy consumption (in kilowatt-hours), for each of the 50 states and the District of Columbia during a recent year. a) Compute the mean, variance, and standard deviation for the population. b) What proportion of these states has per capita energy consumption within + or – 1 standard deviation of the mean, within + or – 2 standard deviations of the mean, and within + or – 3 standard deviations of the mean?...
Western Company allocates $10 overhead to products based on the number of machine hours used. The...
Western Company allocates $10 overhead to products based on the number of machine hours used. The company uses a plantwide overhead rate with machine hours as the allocation base. Given the amounts below, how many machine hours does the company expect in department 2? Estimated: Department 1 Department 2 Manufacturing overhead costs $ 263,000 $ 163,000 Direct labor hours 9,300 DLH 25,000 DLH Machine hours 16,300 MH ? MH Multiple Choice 35,600 MH 146,730 MH 87,830 MH 94,500 MH 26,300...
Westside Energy charges its electric customers a base rate of $4.00 per month, plus 12¢ per...
Westside Energy charges its electric customers a base rate of $4.00 per month, plus 12¢ per kilowatt-hour (kWh) for the first 300 kWh used and 3¢ per kWh for all usage over 300 kWh. Suppose a customer uses x kWh of electricity in one month. (a) Express the monthly cost E as a piecewise defined function of x. (Assume E is measured in dollars.) E(x) = A.  if 0 ≤ x ≤ 300 B.  if 300 < x C. (b) Graph the...
Two electric bulbs of 100 ohms are used for 8 hours daily. What is the cost...
Two electric bulbs of 100 ohms are used for 8 hours daily. What is the cost of them for 1 day if the rate is 75 paise per unit?
2) A sample of customers for Montana Gas and Electric resulted in the following distribution of...
2) A sample of customers for Montana Gas and Electric resulted in the following distribution of monthly charges. Amount ($) Number 0 – 49 13 50 – 99 22 100 – 149 34 150 – 199 26 200 - 249 5 a) What is the probability that a customer has monthly electric cost of $150 or more? b) What is the probability of a customer having a monthly electric cost of less than $150?
A car shop charges a battery using a current of 10 A for 2 hours. How...
A car shop charges a battery using a current of 10 A for 2 hours. How much charge passes through the battery? How many electrons pass through the battery in 1.5 hours
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT