Hi everyone I am typing up an assignment my Professor gave and it is basically just making a bill for a Hotel type service. I have the linked list done and all my calculations and outputs are as needed. But i am getting an infinite loop when the user input is yes or Yes for continuing.
#include <iostream>
using namespace std;
int main()
{
struct nodeType
{
double adults, children, costA, costC, dessert, room, tt, deposit;
nodeType *next, *link;
};
{
nodeType *first,*newNode,*last;
int num;
cout << "Casewell Catering and Convention Service Final Bill\n" << endl;
//cout << "Enter the number of this set: ";
//cin >> num;
// bool choice = true;
char ch;
first = NULL;
do
{
newNode = new nodeType;
newNode->link = NULL;
cout << "Number of Adults: ";
cin >> newNode -> adults;
cout<< "Number of Children: ";
cin >> newNode -> children;
cout<< "Cost Per Adult without dessert: $";
cin >> newNode -> costA;
cout<< "Cost Per Child without dessert: $" << (newNode -> children) *(newNode -> costA) * 0.60 << " (60% of the Adult's meal)" << endl;
cout<< "Cost per dessert: $";
cin >> newNode -> dessert;
cout<< "Room fee: $";
cin >> newNode -> room;
cout<< "Tips and tax rate: $";
cin >> newNode -> tt;
cout << "" << "\n" << endl;
//*********CALCULATIONS********************
cout << "Total cost for adult meals: $" << (newNode -> adults) * (newNode -> costA) << endl;
cout << "Total cost for child meals: $" << (newNode -> children) *(newNode -> costA) * 0.60 << endl;
cout << "Total cost for dessert: $" << ((newNode -> adults) + (newNode -> children)) * (newNode -> dessert) << endl;
cout << "Total food cost: $" <<(newNode -> adults) * (newNode -> costA) +
(newNode -> children) *(newNode -> costA) * 0.60 +
((newNode -> adults) + (newNode -> children)) * (newNode -> dessert)<< endl;
cout << "Plus tips and tax: $" << newNode -> tt * ((newNode -> adults) * (newNode -> costA) +
(newNode -> children) *(newNode -> costA) * 0.60 +
((newNode -> adults) + (newNode -> children)) * (newNode -> dessert)) << " (Does NOT Include Room Fee)" << endl;
cout << "Plus room fee: $" << (newNode -> room) << endl;
// cout << "Less Deposit: $" <<
if(first == NULL)
{
first = newNode;
last = newNode;
}
else
{
last->link = newNode;
last = newNode;
}
cout << "Would you like to continue?(yes/no)" << endl;
cin >> ch;
} while (ch =='y' || ch == 'Y'); // end of while loop
}
return 0;
}