Docsity

Assignment 3 for Structured Problem Solving Using the Computer | ITK 168.00, Assignments of Information Technology

Toggle sidebar
bg1
ACS 168 - Program 3 - Vila
Due date: Tuesday, March 5 before class at 5:30PM.
No extra credit (early or otherwise) will be awarded in this programming
assignment.
The Problem
We have been requested to write a program to create a camping fees report for Illinois State
Park. The campground at Illinois State Park is open to the public, but the fee charged depends
on whether the camper is a resident of Illinois or not and on the length of the stay. The program
needs to determine the fee for each camper and create a summary report about the type of
campers using the park and the fees that have been collected.
The report must print a detail line for each camper who stays at the park. The detail line contains
the camper's ID, the residency (whether the camper is a resident of Illinois or not), the number of
days the camper is staying in the park and the camping fees. The camping fees are determined as
follows: If the camper is from Illinois, the cost for the first seven days is $12.95 per day. After
seven days, the cost drops to $10.95 per day. If the camper is a non-resident, the cost is $15.95
per day, regardless of the number of days. If the residency code is not an R (resident) or an N
(non-resident), the value Unknown is printed in the residency column, the camper is counted as a
non-resident, and the rate is the same as for a non-resident.
After all of the campers have been printed, the summary should include:
the number of in-state campers
the amount of fees collected from in-state campers
the number of out-of-state campers
the amount of fees collected from out-of-state campers
the total number of campers
the total amount of fees collected
the number of campers who stay more than 7 days
Requirements
The design for the problem is given to you. You are to follow the given design, make a desk
check table for the sample data, and write a working C++ program to solve this problem.
The code should be fully documented with comment blocks for all modules (as prescribed in the
Programming Guidelines). You should test the program thoroughly (not just on the test data).
The camper information (record) should be read from standard input (keyboard.) Each record
will consist of a camper’s ID, residency status, and number of days the camper is staying in the
park. The input will be read from the keyboard until the sentinel –999 is typed.
You must allow character input in upper and lower case. You may assume no extra data will be
entered (meaning the user will input exactly one letter for the residency code).
Your summary information should be nicely formatted into neat columns with all dollar amounts
printed using exactly two decimals.
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Assignment 3 for Structured Problem Solving Using the Computer | ITK 168.00 and more Assignments Information Technology in PDF only on Docsity!

ACS 168 - Program 3 - Vila

Due date: Tuesday, March 5 before class at 5:30PM. No extra credit (early or otherwise) will be awarded in this programming assignment. The Problem We have been requested to write a program to create a camping fees report for Illinois State Park. The campground at Illinois State Park is open to the public, but the fee charged depends on whether the camper is a resident of Illinois or not and on the length of the stay. The program needs to determine the fee for each camper and create a summary report about the type of campers using the park and the fees that have been collected. The report must print a detail line for each camper who stays at the park. The detail line contains the camper's ID, the residency (whether the camper is a resident of Illinois or not), the number of days the camper is staying in the park and the camping fees. The camping fees are determined as follows: If the camper is from Illinois, the cost for the first seven days is $12.95 per day. After seven days, the cost drops to $10.95 per day. If the camper is a non-resident, the cost is $15. per day, regardless of the number of days. If the residency code is not an R (resident) or an N (non-resident), the value Unknown is printed in the residency column, the camper is counted as a non-resident, and the rate is the same as for a non-resident. After all of the campers have been printed, the summary should include:  the number of in-state campers  the amount of fees collected from in-state campers  the number of out-of-state campers  the amount of fees collected from out-of-state campers  the total number of campers  the total amount of fees collected  the number of campers who stay more than 7 days Requirements The design for the problem is given to you. You are to follow the given design , make a desk check table for the sample data , and write a working C++ program to solve this problem. The code should be fully documented with comment blocks for all modules (as prescribed in the Programming Guidelines). You should test the program thoroughly (not just on the test data). The camper information (record) should be read from standard input (keyboard.) Each record will consist of a camper’s ID, residency status, and number of days the camper is staying in the park. The input will be read from the keyboard until the sentinel –999 is typed. You must allow character input in upper and lower case. You may assume no extra data will be entered (meaning the user will input exactly one letter for the residency code). Your summary information should be nicely formatted into neat columns with all dollar amounts printed using exactly two decimals.

ACS 168 - Program 3 - Vila

Sample Data (user input in bold) Please enter the Camper’s information (enter –999 to quit): ID: 1234 Residency Code: R Number of Days: 3 ID Residency Days Fee 1234 Resident 3 $38. Enter the next Camper’s information (enter –999 to quit): ID: 3333 Residency Code: r Number of Days: 10 ID Residency Days Fee 3333 Resident 10 $123. Enter the next Camper’s information (enter –999 to quit): ID: 3456 Residency Code: N Number of Days: 5 ID Residency Days Fee 3456 Non-resident 5 $79. Enter the next Camper’s information (enter –999 to quit): ID: 7219 Residency Code: c Number of Days: 9 ID Residency Days Fees 3333 Unknown 9 $143. Enter the next Camper’s information (enter –999 to quit): ID: - Summary Report Number of Campers Fees Collected


In-state: 2 $ 162. Out-of-state: 2 $ 223.


Total 4 $ 385. Number of campers staying more than 7 days: 2

Structure Chart: NOTE: The arrows above indicate the flow of variables into and out of the functions. You should use this information to determine which functions are void, which return a single value, which variables are passed by value, and which variables are passed by reference. If you have questions, ask your instructor. Camp Fees Program Read_Input Calculate_Fee Print_Camper (^) Calc_Totals Print_Summary id res_code days res_code days fee id res_code days fee fee res_code days in_campers out_campers over_week in_fees out_fees in_campers out_campers over_week in_fees out_fees

ACS 168 - Program 3, Vila Algorithms Camp Fees Program main initialize in_campers, out_campers, in_fees, out_fees, and over_week to zero Read_Input WHILE more data Calculate_Fee Print_Camper Calc_Totals Read_Input END WHILE Print_Summary end main Read input Read ID IF ID not ending sentinel Read res_code and days END IF end read input Calculate fee IF res_code = ‘R’ IF days > 7 fee = (7 * 12.95)+((days - 7) * 10.95) ELSE fee = days * 12. END IF ELSE fee = days * 15. END IF return fee end calculate fee print camper print column headings IF res_code = ‘R’ print id, “Resident”, days, fee ELSE IF res_code = ‘N’ print id, “Non-resident”, days, fee ELSE print id, “Unknown”, days, fee END IF END IF end print camper Calc totals IF res_code = 'R' then in_campers = in_campers + 1 in_fees = in_fees + fees ELSE out_campers = out_campers + 1 out_fees = out_fees + fees END IF IF days > 7 then over_week = over_week + 1 END IF end calc totals Print summary Print "Summary Report" Print headings Print in_campers, in_fees Print out_campers, out_fees Print tot_campers, tot_fees Print number staying over_week end print summary

ACS 168 - Program 3, Vila *** Name (please print): _______________________________________________ ULID: ___________________ Section: ____________ Program Score ____________ Late Penalty (-5/day) ____________ FINAL GRADE: ____________ Turn in: Enclosed  Desk Check Table __________  A printout of your program code __________  This grade sheet with *’d items completed __________ Grading remarks

ACS 168 - Program 3, Vila Grading Standards A perfect program will: Run correctly, meeting all specifications from the assignment Follow the given design materials Include a desk check table that tests the sample data Be correctly formatted with clear indentation Be well commented, following the coding guidelines for this class Be submitted correctly, both electronically and on paper (in a pocket folder, with grading sheet and all required materials, etc.) An ‘A’ program: Will run correctly, meeting all specifications from the assignment Will match the given design materials Will include a correct desk check table for the sample data Will have no errors A ‘B’ program: Will run correctly on the example data Will match the given design materials Will include a correct desk check table for the sample data May have minor errors in execution on additional data or several minor errors in design, format, and submission A ‘C’ program: Will compile and run May not match the design exactly May have multiple errors in execution or errors in multiple areas or a single major error in execution A ‘D’ program Will compile and run Has serious errors in execution and/or design An ‘F’ program Does not compile or does not run or has a number of errors of different kinds