View
 

Lab 7: Electric Bill

Page history last edited by Mr. Kretsch 7 months ago

Name: __________________

Objective: Conditional and boolean expressions

Pre-lab Quiz

  1. Write the code for the following function:

  2. Complete the following truth table

    a

    b

    a || b

    !(a || b)

    !a && !b

    T

    T

     

     

     

    T

    F

     

     

     

    F

    T

     

     

     

    F

    F

     

     

     

Lab Instructions

This lab computes an electric bill based on a graduated scale

Getting Started

  1. Create a project called ElectricBill

  2. Import the files from Lab 7 Ebill

Assignment

In your EBill class, write an application (e.g., you will have to create a main method) that calculates an electric bill based on kilowatt usage.

  1. Read in an integer representing the number of kilowatt-hours of electricity used in a household. Program should make sure the number entered is non-negative. If the input is incorrect, the program should display an appropriate message and exit (System.exit())

  2. An electric bill is made up of two costs: a generation cost and a transmission cost. The amount to charge is based on the following table:

Range

Customer Class

Generation

Transmission

< 250 kilowatts

Bronze

Base + (0.04 per Kw)

0.02 per Kw

Between 250 and 1000 kilowatts

Silver

0.04 per Kw

$0.02 per kW

1000 kW or greater

Gold

0.02 per Kw

$0.01 per kW

The Base is $10

  1. The program will print the separate costs, the total cost, and the customer’s class.

Wrap-up

  1. Turn in your source code and grading sheet.

Test

-1

Error

 

 

0

10

0

0

249

19.96

4.98

24.94

250

10

5

15

999

39.96

19.98

59.94

1000

20

10

30

5000

100

50

150

 

 

 

 

 

Grading

 

Points

Correct

Incorrect

Quiz

2

 

 

Input read in from user

Informative prompt

Invalid values detected

Informative error message

4

 

 

Correct bill calculation

Boundary values correctly calculates

6

 

 

Correct output

Separate values as well as totals and customer class

3

 

 

Total points

15

 

 

Notes 

 
 
 
 
 
 

 

 

Comments (0)

You don't have permission to comment on this page.