Computing I C++ Skills Assessment WS XXXXXXXXXX (Prerequisite for Final Exam of Computing II) General Remarks Below you find two programming tasks on successive pages. Both of them have to be...

its attached


Computing I C++ Skills Assessment WS 2019-20 (Prerequisite for Final Exam of Computing II) General Remarks Below you find two programming tasks on successive pages. Both of them have to be successfully completed to pass the skills assessment. Deadline is Tuesday, January 14th, 2020, 24:00. We expect you to submit a zip file comprising the following results: 1. A report (at least ten pages) structured as follows: a. A description of each of the selected programming tasks. You can copy the problem statements listed below. b. Screen shots of the output of each of your programs. c. A short review of your code. Tell us what you think about your work. d. Listings of your C++ code for the selected programming tasks. Please put them into an appendix. This will keep your report more readable. 2. Create a zip file with the following content. a. Report_LastName_FirstName.pdf b. For the first problem, a folder parking. It has to include: main.cpp, parking.h, parking.cpp, and parking.exe. c. For the second problem, a folder zipbar. It has to include: main.cpp, encode.h, encode.cpp, and zipbar.exe. 3. In each case, the file main.cpp is given to you. It implements the main() function of the corresponding task. The other three files are the header file, the associated source file both providing the functions used in the main() function, and the executable. 4. All functions shall be declared in the header files specified, and they shall be defined in the corresponding source files. Apart from the files specified above, no other files are to be uploaded. 5. Your task is to implement the functions called by the main() function for each of the two problems. Note that the executables parking.exe and zipbar.exe both support command line arguments. This makes it easier for us to evaluate your results using a batch file. 6. The inclusion of additional files and libraries besides what has been mentioned above and the C++ standard libraries is not allowed. Put differently, you can use the C++ standard libraries, but in addition only the files mentioned above (parking.h, parking.cpp, encode.h, encode.cpp, and main.cpp in both cases). You have to complete this assignment on your own. Each of your C++ files submitted has to compile in Visual Studio as available on the school’s lab computers in room 1.1.53. Each of your executables must run on these Windows computers as well. We will provide detailed upload instructions during the first week of lectures. Expect us to do some plagiarism checks. If we find tests that match to an unreasonably large degree, then we reserve the right to grade the assignments of everybody involved as failed. Hochschule Würzburg-Schweinfurt Prof. Norbert Strobel Florian Spieß Winter Semester 2019/20 Programming Tasks 1.) Parking Meter This problem is about implementing a parking meter. After a customer has entered the amount of hours she wants to park her car and fed the meter with a certain amount of money, the meter calculates the fee based on a certain fee schedule. Then it returns the appropriate change with as few coins as possible, if any. If the customer has not provided sufficient funds, the parking meter shows how much money is still missing suggesting how it can be provided with a minimum number of coins. An old time slot ends exactly on the half-hour or on the hour. For example, for a half-hour time slot, time values bigger than half an hour (>0.5) would be in the new time slot. For a full-hour time slot, time values bigger than one hour would be in the new time slot (see also screen shots below). The main() function is fully provided. It makes use of the following four functions further explained below: 1. double calculate_fee(double parking_hours); 2. vector calculate_parking_time(double cash); 3. vector convert_to_coins(double return_amount); 4. vector bill_customer(double parking_hours, double amount); Your tasks are: 1. Declare the four functions together with all other necessary C++ header files in the header file parking.h. 2. Define the four functions in the source file parking.cpp. They are explained below. 3. Compile the main() function together with the functions called by it into the executable parking.exe. In what follows, we provide some more details about the four functions: 1. double calculate_fee(double parking_hours) This function calculates the parking costs (type double) based on the input argument parking_hours (type double). This is also the return value of the function. In the table below you will find some examples of the input and expected output values of this function. The calculations are to be carried out as follows: • The parking time is to be expressed in hours, e.g., 1.5 hours for one hour and 30 minutes, or 1.75 hours for 1 hour and 45 minutes. • The first half hour (30 minutes) of parking is free. • Each additional half hour (30 minutes) up to a total parking time of 4.00 hours costs 1 Euro. • The parking fee changes after 4.00 hours of parking. Then each hour costs 1.50 Euro and has to be paid in full, even if the car is not parked for the full hour paid. • If a negative value is provided for parking_hours, the function returns 0. Parking Time (Hours) <= 0="" 0.50="" 1.00="" 2.00="" 4.00="" 4.50="" 5.00="" 5.01="" 8.00="" 8.25="" 16.00="" parking="" fee="" (euros)="" 0.00="" 0.00="" 1.00="" 3.00="" 7.00="" 8.50="" 8.50="" 10.00="" 13.00="" 14.50="" 25.00="" 2.=""> calculate_parking_time(double amount) Given a certain amount of money as input, represented by the variable amount (type double), this function calculates and returns the parking time as a vector of integers. The parking fee schedule remains the same as for the payment() function. The parking time should be returned as vector of length four. Its four elements are to be interpreted as: {nmin, nh, nd, ny}. Here, nmin represents the number of minutes (min), nh the number of hours (h), nd the number of days (d), and ny the number of years (y). We put nmin at the zero position of the vector, nh at the first, nd at the second, and ny is stored with index 3. If amount is negative, a vector with the values {30, 0, 0, 0} should be returned. You can assume that a year has 365 days, a day 24 hours, and an hour 60 minutes. Here are some examples of the relationship between amount and parking time as calculated by the function. Empty fields have the value 0: Amount (Euros) <= 0="" 1.00="" 1.50="" 2.00="" 4.00="" 8.00="" 8.5="" 37.00="" 38.50="" 13141.00="" 13178.50="" nmin="" (minutes)="" 30="" 30="" 30="" nh="" (hours)="" 1="" 1="" 1="" 2="" 4="" 5="" 1="" 1="" nd="" (days)="" 1="" 1="" 1="" ny="" (years)="" 1="" 1="" 3.=""> convert_to_coins(double return_amount) This function calculates how to distribute a certain amount of money over an appropriate number of coins with certain nominal values. The result is to be returned as a vector with eight elements: {n2€, n1€, n50₵, n20₵, n10₵, n5₵, n2₵ , n1₵ }. In this vector, each element represents the number of specific coins, where n2€ is the number of 2€ coins, n1€is the number of 1€ coins, n50₵ is the number of 50₵ coins, n20₵ is the number of 20₵ coins, n10₵ is the number of 10₵ coins, n5₵ is the number of 5₵ coins, n2₵ is the number of 2₵ coins, and n1₵ is the number of 1₵ coins. The element n2€ is at zero position in the vector, the value n1€ has the index position one, etc. until n1₵ at index position seven. Given a certain amount of money as input, return_amount, this function calculates how this amount can be expressed in terms of {n2€, n1€, n50₵, n20₵, n10₵, n5₵, n2₵ , n1₵ }. That is, the vector elements are to be determined. However, not any arbitrary combination of coins will do. The result has to be optimal in the sense that the money has to be returned using as few coins as possible. It is possible to carry out the associated calculations using integer arithmetic to avoid rounding errors. To do this, express all amounts in cents. For a start, multiply the variable return_amount by the factor 100.0 at the beginning of the function. Since this multiplication can lead to calculation inaccuracies due to the internal binary number representation, the result of the multiplication must be rounded correctly before it can be used reliably within the function. This can be accomplished by applying the round() function to the product of return_amount and 100.0. This function is defined in cmath. Here are some inputs and expected results of the function. Empty fields have the value 0: Amount (Euros) -6.22 -3,88 0 0.01 0.03 0.05 0.09 0.88 0.99 1.55 3.88 5.55 n2€ -3 -1 1 2 n1€ -1 1 1 1 n50₵ -1 1 1 1 1 1 n20₵ -1 -1 2 1 n10₵ -1 1 n5₵ -1 1 1 1 1 1 1 n2₵ -1 -1 1 2 2 1 n1₵ -1 1 1 1 4. vector
Jan 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here