can anyone help me do this i am utterly confused and have no clue what to do
Page 1 of 2
Overview: Write a C++ program to select, for purchase, for a particular month, offers to supply coal to an electric generating station. This program should read a user-specified input file containing bids to supply coal. It should then sort the bids from low to high by cost to burn. It should select for purchase the lowest cost bids, subject to the constraint that the total number of tons for all bids selected for purchase must exceed a user-specified amount, but without selecting more bids than minimally necessary. Write the list of selected bids to a user-specified file. Your program should prompt for the information it needs. Do not accept bids for tonnages less than 1000 tons. Example run: Name of file with bids: > Bids1208.txt Number of tons to buy: > 30000 Name of file for selected bids: > Buy1208.txt Format of
Bid Data:
35.00 15.00 0.100 10000 ABC Fuel Co.
37.00 12.50 0.090 15000 BCD Fuel Co.
the first column is the price of the coal at the mine.
The second column is the cost of shipping the coal from the mine to the generating station.
The third column is the fraction of ash in the coal (0.100 means 10 percent ash).
The fourth column is the number of tons of coal offered by the mine.
All text after the fourth column is the name of the mine. Computing Cost to Burn: The cost to burn is equal to the price of the coal at the mine plus the cost of shipping the coal to the generating station plus the cost of disposing of the ash. It costs $100 to dispose of a ton of ash. For the first line above, the cost to burn is $35.00 at the mine plus $15.00 shipping plus $10.00 for ash disposal for a cost to burn of $60.00 for each ton from ABC Fuel Co. Format for Selected Offer Data: Example record: 35.00 10000 ABC Fuel Co. 37.00 15000 BCD Fuel Co. The first column is the price of the coal at the mine. The second is the number of tons of coal to be purchased from the mine. All text after the second column is the name of the mine.
Project 2 Assigned in class November 26
CISC 106, Fall 2008 Due: December 10, 10:00 p.m.
Page 2 of 2
Selecting Coal to Buy: Put the offers into an array of Bids. Sort the Bids into ascending cost to burn. Set a counter to 0, then, while the counter is less than the quantity to purchase, go through the array of Bids in ascending order, selecting the next Bid for purchase and incrementing the counter. Write the selected bids to the designated output file. Do not accept bids for tonnages less than 1000 tons. Running your code: Demonstrate your code by running it for these cases: Case 1: Name of file containing bids: > Bids1208.txt Number of tons to buy: > 60000 Name of file for selected bids: > Buy1208.txt Case 2: Name of file containing bids: > Bids0109.txt Number of tons to buy: > 100000 Name of file for selected bids: > Buy0109.txt Directory containing the two test data files: /www/htdocs/CIS/106/fmcgeary/08F/Project2 Important: You must write, as independent work, the sort routine used to sort the data. You may not use any of the sort algorithms available in C++. You may not use sort routines you find on the Internet. Your sort routine must implement the selection sort algorithm discussed in class. You may derive your sort routine from the code presented in class, but you may not share code with or from any other person or persons, living or dead.

This can't be your first class assignment -- by now you must have some clue about how to write a program and studied input and output file streams. Like any other program, start small, break it down to small parts that you can program. For example, begin by writing a program that prompts for the three things that are needed -- file name of input file, file name of output file, and amount of coal. Looks like you will have to construct your own input file, unless your instructor provided you one.

Your sort routine must implement the selection sort algorithm discussed in class.

This looks like an assignment to test if you paid enough attention in class.
For the rest: I couldn't agree more with the advice of Ancient Dragon!

Comments
Enough? I seriously doubt it was any! :D
This article has been dead for over six months. Start a new discussion instead.