Trying to get the cin function to work in the menu without interfering with the design but having errors. What is the best to use the cin choice function that ask the user to make a choice inside the menu
Trying to get the cin function to work in the menu without interfering with the design but having errors. What is the best to use the cin choice function that ask the user to make a choice inside the menu
#include "stdafx.h"
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <cctype>
#include <iterator>
#include <algorithm>
#include <cmath>
#include "ConsoleApplication13.h"
using namespace std;
string donor_name;
double donor_amount;
int choice;
int main()
{
cout << " \n\n ******************************************************" << endl;
cout << " ******************************************************" << endl;
cout << " ** **" << endl;
cout << " ** **" << endl;
cout << " ** 1. Add a contributor. **" << endl;
cout << " ** 2. Search and update contributor. **" << endl;
cout << " ** 3. Display all Donor information. **" << endl;
cout << " ** 4. Department Total. **" << endl;
cout << " ** 5. Delete Donation. **" << endl;
cout << " ** 6. Exit. **" << endl;
cout << " ** **" << endl;
cout << " ** Choose one: " <<choice << " **" << endl;
cout << " ** **" << endl;
cout << " ** **" << endl;
cout << " ** **" << endl;
cout << " ******************************************************" << endl;
cout << " ******************************************************" << endl;
cin >> choice;
switch (choice)
{
here:
case 1:
cout << "\n===Record donor information===\n";
cout << "\nPlease enter the name of the donor: \n";
cin >> donor_name;
cout << "\nPlease enter amount donor contributed: \n";
cin >> donor_amount;
cout << "\n\n=Donation to organization= \n";
cout << "\n1.)NHTS 2)PBL 3)PTK 4)SEA\n";
system("CLS");
goto here;
case 2:
cout << "==Search and update contributor==";
system("CLS");
goto here;
case 3:
cout << "==Display all donations==";
system("CLS");
goto here;
case 4:
cout << "==Total Contributions==";
system("CLS");
goto here;
case 5:
cout << "==Delete a donor donation==";
system("CLS");
goto here;
case 6:
exit(0);
}
system("pause");
system("CLS");
return 0;
}
Step by step
Solved in 2 steps