1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Regarding Total Electric Bill and its Pseudocode

Discussion in 'C++' started by kslpeter87, Jul 27, 2007.

  1. kslpeter87

    kslpeter87 New Member

    Joined:
    Jul 20, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    Write a pseudocode to calculate the total electric bill
    0-999 KWH
    Commercial rate class 0.49
    R1 rate class 0.57
    R2 rate class 0.60

    1000-1499 KWH
    Commercial rate class 0.38
    R1 rate class 0.43
    R2 rate class 0.44
    R3 rate class 0.45

    1500-1999 KWH
    Commercial rate class 0.31
    R1 rate class 0.40

    2000 or more KWH
    Commercial rate class 0.29
    R1 rate class 0.31
    R2 rate class 0.35

    This is what i've done, Stucked

    Algorithm: Calculate total electric bill from different classes
    1. start
    2. Read Class ('C', 'r1', 'r2', or 'r3')
    3. Calculate C class total electric bill.
    4. Calculate r1 class total electric bill.
    5. Calculate r2 class total electric bill.
    6. Calculate r3 class total electric bill.
    7. Display Total, Class
    8. End

    Algorithm: Calculate C class total electric bill.
    1. Start
    2. Read KWH
    3. If ( KWH <= 999 ) Total = KWH * 0.49
    If ( KWH <= 1499 ) Total = ( KWH-999 ) * 0.38 + 489.51(489.51=999*0.49)
    If ( KWH <= 1999 ) Total = ( KWH-1499 ) * 0.31 + 679.51
    If ( KWH > 1999 ) Total = ( KWH-1999 ) * 0.29 + 834.51
    4. Return

    Algorithm: Calculate r1 class total electric bill
    1. Start
    2. Read KWH
    3. If ( KWH <= 999 ) Total = KWH * 0.57
    If ( KWH <= 1499 ) Total = ( KWH-999 ) * 0.43 + 569.43
    If ( KWH <= 1999 ) Total = ( KWH-1499 ) * 0.40 + 784.43
    If ( KWH > 1999 ) Total = ( KWH-1999 ) * 0.31 + 984.43
    4. Return

    Algorithm: Calculate r2 class total electric bill
    1. Start
    2. Read KWH
    3. If ( KWH <= 999 ) Total = KWH * 0.60
    If ( KWH <= 1499 ) Total = ( KWH-999 ) * 0.44 + 599.4
    how to write this part??
    If ( KWH > 1999 ) Total = ( KWH-1999 ) * 0.35 + ???
    4. Return

    The same problem goes to r3 class.

    That's my 1st Programming assignment, sadly i cant complete it

    i'll be grateful if someone kind could help, any other ways of doing it i'll accept, Thanks
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    1500-1999 KWH R2 data is not provided and so you cannot write and so you are stuck. Either you are given the wrong problem statement or whatever is given if its correct your solution is also correct.
     
  3. kslpeter87

    kslpeter87 New Member

    Joined:
    Jul 20, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    Thank you shabbir.

    Since you agree that way too, then i'd just pass it up like that la.

    See how my lecturer mark it. I'll tell you the result after Monday la.;)
     

Share This Page