| | |
water program using subprograms
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
•
•
Join Date: Oct 2004
Posts: 7
Reputation:
Solved Threads: 0
Hello, I have this code, but it does not work, i everytime i fix one error i get more, i have attached the assignment, and then my work, thanks for any help or pointers in the right direction
Write a program to calculate and print out water bills.
The rates vary depending on whether the customer is a home user (code H), a commercial user (Code C) or an industrial user (Code I). No other code should be accepted. The rates are as follows:
Code H: A flat $5.00 fee plus $0.0005 per gallon used.
Code C: $1000 for the first 4 million gallons used plus $0.00025 for each additional gallon.
Code I: $1000 for up to and including 4 million gallons; $2000 for more than 4 million gallons up to and including 10 million gallons; and $3000 for more than 10 million gallons.
Inputs from the user are a four-digit account number (you don't need to error check this), the user code, and the number of gallons used. The valid user codes should be required and the number of gallons used should be equal to or greater than 0.
The output should display all the input as well as the amount of the bill neatly with descriptive text.
At minimum, the program should use separate subprograms for getting input, calculating the amount of the bill, and producing output.
NOTE: In order to use pass by value, the subprogram that gets the input should call the subprogram that calculates the bill, and the subprogram that calculates the bill should call the subprogram that produces output.
********************* here is my work************************
PROGRAM week_6_Program_3 (input, output);
Uses
sysutils;
var
acc_num,code,num_gallons : integer;
PROCEDURE Input; { get needed input to run the procedure}
begin
writeln ('Please enter in customers 4 digit account number:');
readln (acc_num);
writeln ('Please enter user code
C,H,I)');
readln (Code);
writeln ('How many gallons of water were used:');
readln (num_gallons)
while num_gallons < 0 do
writeln ('Gallons used must be greater then or equal to 0 gallons used!');
writeln ('How many gallons of water were used:');
readln (num_gallons);
end;
PROCEDURE CalculateBill;
BEGIN
case code of
'H' = 5.00 + (0.0005 * num_gallons);
'C' = 1000
If (num_gallons > 4000000) then
C = 1000 + (0.00025 * num_gallons);
'I' = 1000
IF (num_gallons > 4000001) and (num_gallons < 10000000) then
I = 2000
else
IF
(num_gallons > 10000001) then
I = 3000
END;
PROCEDURE output
BEGIN
writeln (' Your four digit account number is: ',acc_num:4:0);
writeln ('Your user code is: ',code);
writeln (' Your total water usage is: ',num_gallons,);
writeln ('Your total bill is:', total_bill);
begin
input;
calculatebill;
output;
writeln ('Press <enter> to exit!');
readln;
end.
thanks again for any pointers :c
Write a program to calculate and print out water bills.
The rates vary depending on whether the customer is a home user (code H), a commercial user (Code C) or an industrial user (Code I). No other code should be accepted. The rates are as follows:
Code H: A flat $5.00 fee plus $0.0005 per gallon used.
Code C: $1000 for the first 4 million gallons used plus $0.00025 for each additional gallon.
Code I: $1000 for up to and including 4 million gallons; $2000 for more than 4 million gallons up to and including 10 million gallons; and $3000 for more than 10 million gallons.
Inputs from the user are a four-digit account number (you don't need to error check this), the user code, and the number of gallons used. The valid user codes should be required and the number of gallons used should be equal to or greater than 0.
The output should display all the input as well as the amount of the bill neatly with descriptive text.
At minimum, the program should use separate subprograms for getting input, calculating the amount of the bill, and producing output.
NOTE: In order to use pass by value, the subprogram that gets the input should call the subprogram that calculates the bill, and the subprogram that calculates the bill should call the subprogram that produces output.
********************* here is my work************************
PROGRAM week_6_Program_3 (input, output);
Uses
sysutils;
var
acc_num,code,num_gallons : integer;
PROCEDURE Input; { get needed input to run the procedure}
begin
writeln ('Please enter in customers 4 digit account number:');
readln (acc_num);
writeln ('Please enter user code
C,H,I)');readln (Code);
writeln ('How many gallons of water were used:');
readln (num_gallons)
while num_gallons < 0 do
writeln ('Gallons used must be greater then or equal to 0 gallons used!');
writeln ('How many gallons of water were used:');
readln (num_gallons);
end;
PROCEDURE CalculateBill;
BEGIN
case code of
'H' = 5.00 + (0.0005 * num_gallons);
'C' = 1000
If (num_gallons > 4000000) then
C = 1000 + (0.00025 * num_gallons);
'I' = 1000
IF (num_gallons > 4000001) and (num_gallons < 10000000) then
I = 2000
else
IF
(num_gallons > 10000001) then
I = 3000
END;
PROCEDURE output
BEGIN
writeln (' Your four digit account number is: ',acc_num:4:0);
writeln ('Your user code is: ',code);
writeln (' Your total water usage is: ',num_gallons,);
writeln ('Your total bill is:', total_bill);
begin
input;
calculatebill;
output;
writeln ('Press <enter> to exit!');
readln;
end.
thanks again for any pointers :c
![]() |
Similar Threads
- Help with Water Temperature program (C++)
- help with hangman program (Java)
- Hi i'm having trouble with writing a program (C)
- Strings Program (C++)
- Program using a Menu Selection with Subprograms (C++)
- program w/ switch AND nested if. six error messages (C++)
- Amature Program- Lacking (C++)
- problem with my program!! (C++)
Other Threads in the Computer Science Forum
- Previous Thread: What are turbo c function?
- Next Thread: Intelligent Redirect
| Thread Tools | Search this Thread |
Tag cloud for Computer Science
ai algorithm algorithms amazon assignment assignments automata battery bigbrother binary bizarre bletchleypark blogging bomb business cern codebreaker compiler computer computers computerscience computertrackingsoftware connect conversion csc data dataanalysis dataintepretation development dfa dissertation dissertationtopic ebook energy extensions floatingpoint foreclosure foreclosuresoftware fuel gadgets geeks givemetehcodez government graphics hardware history homeowners homeworkassignment homeworkhelp humor ibm idea ideas internet iphone ipod jobs laser laws linkbait lsmeans mainframes mining mobileapplication msaccess nano netbeans networking news os p2p parser piracy piratebay principles programming rasterizer research sam-being-cute sas science security sex simulation software spying sql stephenfry study supercomputer supercomputing sweden technology textfield tree turing turingtest virus warehouse ww2





