Hey guys, i'm doing some work and really need some help. I'll paste the code I wrote thus far. I have this to work without a loop, but I can not get it to work with a loop.
I would like to have an exit word "quit" when it pops up to ask me my name. I tried for hours googling and going through my book how to get a worded loop to work and atlas I couldn't get any damn loop to work no matter how hard I tried.
do
{
cout << "What is your name?" << endl;
getline(cin, cName); // Ask for name
if (cName != "quit") // if name is quit, then jump over all the other steps and go to the end
{
cout << "What is your state? (Please enter the complete name)" << endl;
getline(cin, cState);
cout << "What is the product price" << endl;
cin >> pPrice;
if (pPrice > 50)
pDiscount = .15 * pPrice;
else
pDiscount = 0;
dPrice = (pPrice - pDiscount);
if (cState == "Indiana")
sTax = .07 * dPrice;
else
sTax = 0;
tCost = dPrice + sTax;
cout << "Name: " << cName << endl;
cout << "state: " << cState << endl;
cout << "Price: " << pPrice << endl;
cout << "Discount Price: " << dPrice << endl;
cout << "Tax: " << sTax << endl;
cout << "Final price: " << tCost << endl;
}
} while (cName != "quit"); // after all steps have been skipped, this will exit the loop
Dont forget that, Nowadays, Youtube is also a very great resource. There are plenty of tutorials!