I am new to c++ and I need use my functions to store multiple user inputs and then print multiple user inputs. However, my code only does one user input. Should I store it in an array? It is self-explanatory code, so you can skip to the bottom and look for the "??storeinvariable??"
#include <iostream>
using namespace std;
// Will display all bids
void displayBid(string &bidTitle, string &fundPerson, string &vehicleId, float &bidAmount)
{
cout << "Title: " << bidTitle << endl;
cout << "Fund: " << fundPerson << endl;
cout << "Vehicle: " << vehicleId << endl;
cout << "Bid Amount: " << bidAmount << endl;
}
// Ask the user for title, person, vehicleId, amount
void getBid(string &bidTitle, string &fundPerson, string &vehicleId, float &bidAmount)
{
cout << "Enter Title: ";
cin.ignore();
getline(cin, bidTitle);
cout << "Enter Fund";
cin.ignore();
getline(cin, fundPerson);
cout << "Enter Vehicle ID: ";
cin.ignore();
getline(cin, vehicleId);
cout << "Enter Bid Amount: ";
cin.ignore();
cin >> bidAmount;
}
// Loops through adding bids or displaying bids
main(void)
{
string title, person, id;
title = "";
person = "";
id = "";
float amount;
amount = 0.0;
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;
switch (choice) {
case 1:
??storeinvariable?? = getBid(title, person, id, amount);
break;
case 2:
// display variable??
displayBid(title, person, id, amount);
break;
}
}
cout << "Good bye." << endl;
return 1;
}