Question: Hello, This is the first program I have worked on in C++ so I am doing my best but have a few errors. Could you

Hello,

This is the first program I have worked on in C++ so I am doing my best but have a few errors. Could you please help me correct the errors? Thank you!

#include

#include

using namespace std;

//============================================================================

// Global definitions visible to all methods and classes

//============================================================================

// FIXME (1): Define a data structure to hold bid information together as a single unit of storage.

struct Bids {

string title = "";

string fund = "";

string vehicleID = 0;

double bidAmt = 0;

};

// FIXME (4): Display the bid values passed in data structure

/**

* Display the bid information

*

* @param Bids data structure containing the bid info

*/

void displayBid(Bids bidItem) {

cout << "Title: " << bidItem.title << endl;

cout << "Fund: " << bidItem.fund << endl;

cout << "Vehicle: " << bidItem.vehicleID << endl;

cout << "Bid Amount: " << bidItem.bidAmt << endl;

return;

}

/**

* Simple C function to convert a string to a double

* after stripping out unwanted char

*

* credit: http://stackoverflow.com/a/24875936

*

* @param ch The character to strip out

*/

double strToDouble(string str, char ch) {

str.erase(remove(str.begin(), str.end(), ch), str.end());

return atof(str.c_str());

}

// FIXME (3): Store input values in data structure

/**

* Prompt user for bid information

*

* @return data structure containing the bid info

*/

void getBid(Bids & bidInfo) {//is this right?

cout << "Enter title: ";

cin.ignore();

getline(cin, bidInfo.title);

cout << "Enter fund: ";

cin >> bidInfo.fund;

cout << "Enter vehicle: ";

cin.ignore();

getline(cin, bidInfo.vehicleID);

cout << "Enter amount: ";

cin.ignore();

string strAmount;

getline(cin, strAmount);

bidInfo.bidAmt = strToDouble(strAmount, '$');

return; //**I do not know what to return**//

}

/**

* The one and only main() method

*/

int main() {

//FIXME (2): Declare instance of data structure to hold bid information

Bids bidInfo;

// loop to display menu until exit chosen

int choice = 0;

while (choice != 9) {

cout << "Menu:" << endl;

cout << " 1. Enter Bid" << endl;

cout << " 2. Display Bid" << endl;

cout << " 9. Exit" << endl;

cout << "Enter choice: ";

cin >> choice;

// FIXME (5): Complete the method calls then test the program

switch (choice) {

case 1:

= getBid();//Not sure what to do here either

break;

case 2:

displayBid(bidInfo);

break;

}

}

cout << "Good bye." << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!