Starting from:
$35

$29

For Sale or Wanted Message Board


Please read the entire assignment carefully before beginning. In this assignment, you’re going to develop a simulated message board that monitors items wanted and items for sale and looks for matches. When a match is found, e.g. there is a bike for sale for $50 and a bike wanted, where the buyer will pay up to $60, then the item is removed from the message board.

There is a file on Canvas called items.txt that includes up to 100 wanted or for sale items in five categories: bike, microwave, dresser, truck, or chicken. Each line in the file is one item. The code should assume that there will never be more than 100 lines in the file, therefore, the array of structs has a fixed size of 100 to represent the items available on the message board. Each struct represents an item and has a type, such as bicycle or truck, a price, and whether it is for sale or wanted. (The for sale or wanted is represented as a Boolean, where 0 is for sale and 1 is wanted.)

The data in the file is read into the array by the program, your program needs to read the array and check if there is a match between the existing items in the message board. There are two options to consider:

Match is not found in the new array

If a match is not found in the array, print the information about the unmatched item using the commands:

cout<<”Match not found”<<endl; cout<<itemArray[x].type<<” “<<itemArray[x].price<<endl;

Match is found in the new array

If a match is found in the new array, use the best match found, and remove the matched items from the array and shift the array to fill the gaps left by the removed items. (Section 3.2.4 of your data structures e-book shows the algorithm for deleting an item from an array and shifting.) Print the action performed, using the command:

cout<<itemArray[x].type<<” “<<itemArray[x].price<<endl;

where itemArray is the array of structs and x is the index where the for sale item was found in the array. The type is one of the following: bike, microwave, dresser, truck, or chicken. The price is the actual item cost, not what the user is willing to pay.

Other things your program needs to do

Use definitions for best match

You need to find the maximum profit for the seller.

Your program should have a separate function for maximum profit

How to know if your output is correct?

There is a Piazza forum for this class, and you are welcome to post the output you get for the sample garageSale.txt file on Piazza and not item.txt and ask if other students get the same answer. If you want to test your code with a smaller data set, create a new .txt file and use that file as the input file when you run your code. Please don’t post your code on Piazza.

What is a Struct?

I talked about structs in class on Friday. For more information on what structs are and how to create them, there are videos on the CU Boulder Data Structures CSCI 2270 YouTube channel that describe structs in more detail. The videos are Data Structures Tutorial 9 and 10.

Submitting Your Code:

Submit your assignment to Canvas

Submit your .cpp file through Canvas using the Assignment 1 Submit link. Make sure your code is commented enough to describe what it is doing. Include a comment block at the top of the .cpp file with your name, assignment number.

.

More products