1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
arlik [135]
3 years ago
7

The electric company gives a discount on electricity based upon usage. The normal rate is $.60 per Kilowatt Hour (KWH). If the n

umber of KWH is above 1,000, then the rate is $.45 per KWH. Write a program (L4_Ex1.cpp) that prompts the user for the number of Kilowatt Hours used and then calculates and prints the total electric bill. Please put comment lines, same as in Lab3, at the beginning of your program. According to your program in Lab 4.1, how much will it cost for: 900 KWH? 1,754 KWH? 10,000 KWH?
Computers and Technology
1 answer:
katrin2010 [14]3 years ago
3 0

Answer:

The cpp program for the given scenario is shown below.

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

   //variables to hold both the given values

   double normal_rate = 0.60;

   double rate_1000 = 0.45;

   //variable to to hold user input

   double kwh;

   //variable to hold computed value

   double bill;

   std::cout << "Enter the number of kilowatt hours used: ";

   cin>>kwh;

   std::cout<<std::endl<<"===== ELECTRIC BILL ====="<< std::endl;

   //bill computed and displayed to the user

   if(kwh<1000)

   {

       bill = kwh*normal_rate;

       std::cout<< "Total kilowatt hours used: "<<kwh<< std::endl;

       std::cout<< "Rate for the given usage: $"<<normal_rate<< std::endl;

       std::cout<< "Total bill: $" <<bill<< std::endl;

   }

   else  

   {

       bill = kwh*rate_1000;

       std::cout<< "Total kilowatt hours used: "<<kwh<< std::endl;

       std::cout<< "Rate for the given usage: $"<<rate_1000<< std::endl;

       std::cout<< "Total bill: $" <<bill<< std::endl;

   }

   std::cout<<std::endl<< "===== BILL FOR GIVEN VALUES ====="<< std::endl;

   //computing bill for given values of kilowatt hours

   double bill_900 = 900*normal_rate;

   std::cout << "Total bill for 900 kilowatt hours: $"<< bill_900<< std::endl;

   double bill_1754 = 1754*rate_1000;

   std::cout << "Total bill for 1754 kilowatt hours: $"<< bill_1754<< std::endl;

   double bill_10000 = 10000*rate_1000;

   std::cout << "Total bill for 10000 kilowatt hours: $"<< bill_10000<< std::endl;

   return 0;

}

OUTPUT

Enter the number of kilowatt hours used: 555

===== ELECTRIC BILL =====

Total kilowatt hours used: 555

Rate for the given usage: $0.6

Total bill: $333

===== BILL FOR GIVEN VALUES =====

Total bill for 900 kilowatt hours: $540

Total bill for 1754 kilowatt hours: $789.3

Total bill for 10000 kilowatt hours: $4500

Explanation:

1. The program takes input from the user for kilowatt hours used.

2. The bill is computed based on the user input.

3. The bill is displayed with three components, kilowatt hours used, rate and the total bill.

4. The bill for the three given values of kilowatt hours is computed and displayed.

You might be interested in
TRUE OR FALSE - SQL language is used to query data in a Relational Database?
Gelneren [198K]

Answer:

Yes I agree with the other person who answered that

5 0
2 years ago
To join a social network you create an avatar true or false
svp [43]
False because not all social media webstites provide avatars
7 0
3 years ago
Read 2 more answers
Modern ssds use a technique called "____" to spread write operations around the storage medium, thus evening out the impact of d
masha68 [24]

The question above has multiple choices as below;

<span>a.      </span>Wear aggregation.

<span>b.      </span>Wear mitigation.

<span>c.      </span>Wear prevention

<span>d.      </span>Wear leveling

The answer is d) Wear leveling.


This technique by some SSD controllers to increase the memory’s lifetime is called wear leveling. The mechanism for this principle is simple: distribute the entries for all the blocks evenly so that they will wear out evenly. Flash controller typically manages wear leveling and uses a wear leveling algorithm to control which physical block to use.







7 0
2 years ago
Choose the word that best completes this sentence. ________ can only grow and multiply within the cells of another living thing,
melomori [17]
The correct answer that would best complete the given statement above would be the word VIRUSES. Here is the complete statement. Viruses can only grow and multiply within the cells of another living thing, but they can remain active on a surface for several hours or days.
4 0
2 years ago
Python exercise grade 10
Lemur [1.5K]

nums = []

while True:

   num = float(input("Enter a number: "))

   if num <= 0:

       break

   nums.append(num)

print("The largest number entered was",max(nums))

I wrote my code in python 3.8. I hope this helps.

5 0
3 years ago
Other questions:
  • Your friend sends you a computer game. after installing the game on your computer, you realize that it plays very slowly. you kn
    14·1 answer
  • Ethics is a way of behaving so that you are
    7·2 answers
  • Green Field county stadium is planning to conduct a cricket match between two teams A and B. A large crowd is expected in the st
    6·1 answer
  • 15
    9·2 answers
  • Three homework questions I can't figure out, please help?
    11·1 answer
  • Each wireless network has its own name to identify it, known as service set identity. true false
    9·1 answer
  • Charlie makes pizza at a restaurant. The customers always compliment how great the pizza tastes. But Charlie takes a long time t
    7·2 answers
  • And, or, not are examples of boolean logic
    5·1 answer
  • True or False
    9·1 answer
  • Which of the following formats can algorithms NOT be written in:
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!