C++ program problem

  • Topic: C/C++ 
  • Thread starter Amr719
  • Start date
  • Tags Tags
    C++ Program
4 replies · 2K views · last reply
Amr719
Messages
31
Reaction score
0
Screenshot of the EES Equations Window showing a function charge(con) with nested if-else logic for electricity cost, with two lines highlighted in red boxes: cost=10+0.05*(units-500) and cost=35+0.1*(units-1000).
 
The lines in blue in your image pretty well explain what is happening in the pseudocode. Are you having trouble understanding the problem description?
 
No I understand the description. But I don't understand the form of writing the code . Why in the first line he wrote units -500 and why in the second line he wrote units - 1000
 
"every unit in excess of 1000" is (units - 1000)

So the code is a direct translation of the description above.
 
  • Like
Likes   Reactions: pugwazup19755 and Amr719