CSCI 1010 Programming Assignment 11 Learning Outcomes • Use parallel arrays and files as input and output. Required Reading Gaddis - Sections XXXXXXXXXX Instructions Note: Some data input to this...

How much



CSCI 1010 Programming Assignment 11 Learning Outcomes • Use parallel arrays and files as input and output. Required Reading Gaddis - Sections 7.6-7.9 Instructions Note: Some data input to this program and some program output depends on your name. If you do not use your name as required, points will be deducted for this assignment. (Your full name)s Trucking Company has a file called TruckInput.txt which contains the following information: • Truck Number (an int) • Fuel Cost (a double) • Equipment Insurance (a double) • Miles Driven (a int) The company pays its drivers $0.50 per mile driven. The company also pays out a bonus of $100 to the truck’s driver if the driver has driven 100 miles or more in a single trip. Assume the company has up to 15 trucks. Write a C++ program that does the following: • Create two parallel arrays (one for the truck numbers, the other for the final truck costs.) • Read in the data from the file. • Calculate the final cost per truck (including driver’s bonus if applicable). • Display all information to the console including driver bonus (if any) and final truck cost. • Store the truck number and calculated final truck cost in the arrays. • Create an output file called TruckCost.txt that contains the contents of the arrays in reverse order. 1 Example Input and Output TruckInput.txt should look like this: 111 100.00 200.00 50 222 200.00 300.00 100 333 400.00 500.00 200 Note that each line contains the truck number, fuel cost, equipment cost, and miles driven in that order. The display should look like this: Welcome to Jarad Sneeds Trucking Company Truck No Fuel Equipment Miles Mileage Pay Driver Bonus Final Cost 111 100.00 200.00 50 25.00 0.00 325.00 222 200.00 300.00 100 50.00 100.00 650.00 333 400.00 500.00 200 100.00 100.00 1100.00 Totals 700.00 1000.00 350 175.00 200.00 2075.00 Note the Mileage pay is calculated by multiplying the number of miles by 0.50, and the final cost is the sum of the fuel cost, equipment cost, mileage pay, and driver bonus. TruckCost.txt should look like this: 333 1100.00 222 650.00 111 325.00 Note that the records are in reverse order. This is why we need the arrays for the truck numbers and final costs. Notes and Comments The name of the file you hand in must be your last name followed by Assign11 with the extension .cpp. For example, mine would be sneedAssign11.cpp. Make sure to include comments with your name, a description of what the program does, the course (CSCI 1010), and the assignment name (Programming Assignment 11) at the beginning of your source file. Make sure you only hand in the source file for your assignment, not the executable file, or any other files that Visual Studio creates. Your programs must compile without errors in order to be graded. Once your program compiles make sure to test it using multiple test cases to see if it meets the requirements of the assignment. 2
Oct 09, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here