The energy company in Program 1 now uses different rates for residential and business customers. Residential customers pay $0.12 per kWh for the first 500 kWh. After the first 500 kWh, the rate is $0.15 per kWh. Business customers pay $0.16 per kWh for the first 800 kWh. After the first 800 kWh, the rate is $0.20 per kWh. Write a program to calculate energy charge. You must write and use the following two functions. (a)A main function: Ask the user to enter number of kWh used and customer type (enter R for residential or B for business). Call the bill_calculator function and pass number of kWh used and customer type to it as arguments. You must use positional arguments to pass kWh used and customer type. (b)A bill_calculator function: This function has two parameters to receive number of kWh used and customer type. Calculate and display the energy charge.

Answers

Answer 1
Answer:

Answer:

The c# program for the scenario is given below.

using System;

public class Program2 {

 double total = 0;

 static void Main() {

     Program2 ob = new Program2();

   Console.WriteLine("Enter total energy used in kilo watts ");

   int p;

   p = Convert.ToInt32(Console.ReadLine());

   Console.WriteLine("Enter type of customer ");

   char t;

   t = Convert.ToChar(Console.ReadLine());

   ob.bill_calculator(p, t);

   Console.WriteLine("Total charge for " + p + " kilo watts electricity for " + t + " customers is " + ob.total);

 }

 public void bill_calculator(int e, char c)

 {

     int first=500, second = 800;

     double chg_one = 0.12, chg_two=0.15, chg_three = 0.16, chg_four = 0.20;

     if(c == 'R')

     {

        if(e <= 500)

        {      

            total = (e * chg_one);

        }

        else if(e > 500)

        {

           total = ( first * chg_one);

           total = total + ((e-first) * chg_two);

        }

     }

     if(c == 'B')

     {

        if(e <= 800)

        {      

          total = (e * chg_three);

        }

        else if(e > 800)

        {

          total = ( first * chg_three);

          total = total + ((e-second) * chg_four);

        }

     }

  }

}

OUTPUT

Enter total energy used in kilo watts                                                                                                            

1111                                                                                                                                            

Enter type of customer                                                                                                                          

B                                                                                                                                                

Total charge for 1111 kilo watts electricity for B customers is 142.2

Explanation:

The program takes user input for the type of customer and the amount of electric current used by that customer.

The two input values decide the rate at which total charge is calculated.

For residential customers, charges are divided into slabs of 500 or less and more than 500.

Alternatively, for business customers, charges are divided into slabs of 800 or less and more than 800.

User input is taken in main function.

Charges are calculated in the bill_calculator method which takes both user input as parameters.

If else block is used to calculate the charges.

No input validation is implemented as it is not mentioned in the question.

All code is written inside the class. An object is created of the class.

The methods outside main() are called using the object of the class.


Related Questions

Perform depth-first search on each of the following graphs; whenever there's a choice of vertices, pick the one that is alphabetically first. Classify each edge as a tree edge, forward edge, back edge, or cross edge, and give the pre and post number of each vertex.
How to solve the problem in the man middle attack?
Complete the sentence about a presentation delivery method. A(n) ____ allows you to transmit your presentations over the Internet using ____.1: A. Presentation softwareB. webcastC. external monitor2: A. ProjectorsB. CDsC. Streaming technology
A customer has engaged your software development company to develop a new order-processing system. However, the time frames are very tight and inflexible for delivery of at least the basic part of the new system. Further, user requirements are sketchy and unclear. a. What is the best system development strategy that might be advantageous to use in this engagement? b. What is the potential downside to using the strategy described in the part a?
A firewall is either software or dedicated hardware that exists between the __________ being protected.

How many times will the following loop display "Looping again!"? for(int i=0; i<=20; i++) cout << "Looping again!" << endl;

Answers

Answer:

21 times

Explanation:

Following are the description of output:

  • As it is for loop and The loop is started from the i=0 , after that check the condition 0<=20 condition is true .The control moves to the body of loop and it print Looping again! on the console window .After that it increment the value of i=i+1 .
  • Now i=1  1<=20  condition is true .The control moves to the body of loop and it print Looping again! on the console window .After that it increment the value of i=i+1 .
  • i=2 2<=20 condition is true .The control moves to the body of loop and it print Looping again! on the console window .After that it increment the value of i=i+1 .
  • ............soon
  • This process is executed again and again but when the value i=21 the loop condition is false .The loop is terminated .
  • As the loop is starts from the i=0 and executed less then equal to 20 therefore 21 times the loop is executed .

An analyst receives an alert from the SIEM showing an IP address that does not belong to the assigned network can be seen sending packets to the wrong gateway. Which of the following network devices is misconfigured and which of the following should be done to remediate the issue? A. Firewall; implement an ACL on the interface B. Router; place the correct subnet on the interface C. Switch; modify the access port to trunk port D. Proxy; add the correct transparent interface

Answers

Answer: (A)  Firewall; implement an ACL on the interface

Explanation:

 According to the question, for re-mediate the issue firewall should be implemented the ACL (Access control list) on the given interface. The access control list is one of the type of logic which selectively give permission or deny the number of packet in the system which to through the interface.

Firewall is the type of device that basically examine the traffic in the network system and also make several decisions in the system. ACL is the set of rule which mainly define the route of the packet in the router interface state.

A user logging on, an application server connecting to a database server, an authentication server rejecting a password, or an antivirus scanner reporting a suspected virus are all examples of:

Answers

The answer is Event.  A user logging on, an application server connecting to a database server, an authentication server rejecting a password, or an antivirus scanner reporting a suspected virus are all examples of Event.

Discuss thefactors that are vital to achieve clarity in themessage?

Answers

Answer:

The clarity factor suggest that if there is lack of clarity communication can do a great deal of damage. The Clarity Factor is a perfect example of a well chosen words and well written sentences can get the most complicated in the message across the number of people in the least amount of the time.

The factors that are vital to achieve clarity in the messages are:

  • Your mind has to process everything that create space cross your vision. If your home and your work environment is messy, then it results in brain messy. So, be clear with your thoughts and vision.
  • Passionate about your work and life and then create thoughts.  
  • When you are writing just write, be focused with your work.

A proper divisor of a positive integer $n$ is a positive integer $d < n$ such that $d$ divides $n$ evenly, or alternatively if $n$ is a multiple of $d$. For example, the proper divisors of 12 are 1, 2, 3, 4, and 6, but not 12. A positive integer $n$ is called double-perfect if the sum of its proper divisors equals $2n$. For example, 120 is double-perfect (and in fact is the smallest double-perfect number) because its proper divisors are 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, and 60, and their sum is 240, which is twice 120. There is only one other 3-digit double-perfect number. Write a Python program to find it, and enter the number as your answer below.

Answers

Answer:

The program written in Python is as follows:

See Explanation section for line by line explanation

for n in range(100,1000):

     isum = 0

     for d in range(1,n):

           if n%d == 0:

                 isum += d

     if isum == n * 2:

           print(n)

Explanation:

The program only considers 3 digit numbers. hence the range of n is from 100 to 999

for n in range(100,1000):

This line initializes sum to 0

     isum = 0

This line is an iteration that stands as the divisor

     for d in range(1,n):

This line checks if a number, d can evenly divide n

           if n%d == 0:

If yes, the sum is updated

                 isum += d

This line checks if the current number n is a double-perfect number

     if isum == n * 2:

If yes, n is printed

           print(n)

When the program is run, the displayed output is 120 and 672

How many rules are contained in the css code?
a.1
b.2
c.3
d.4​

Answers

I strongly agree that B is the answer
Other Questions