I am probably well on the wrong path with this one which is why I can't get the program to compile in the slightest.
The assignment instructions are :
The Frozen Tongue Ice Cream Shop sells six flavors of ice cream: chocolate, vanilla, strawberry, mint, rocky road, and
mocha. The shop wants a program that tracks how many scoops of each flavor are sold each day. The console input for each transaction will be the name of a flavor followed by how many scoops of that flavor were sold in that transaction:example of initial output:
Enter the flavor of the scoops sold (STOP to exit): vanilla
Enter how many scoops were sold: 3If the user enters a flavor that doesn't match any of the known flavors, the program should display an error message. The user should be allowed to enter as many transactions as desired, and each flavor will likely appear in more than one transaction. Once the user enters "STOP", the program should terminate, and the program should display how many scoops of each flavor were tallied in the program run:
DAILY SCOOP REPORT:
Chocolate: 58
Vanilla: 65
Strawberry: 49
Mint: 23
Rocky Road: 37
Mocha: 31
One way to make sure that the scoops are added to the proper flavor counter is to have a series of decision statements comparing the user's input to each flavor. Another approach would be to use parallel arrays, with an array of strings storing the name of the each flavor and an array of integers storing the count for each flavor at the same index as the
flavor name in the other array.Write your code so that it handles the flavor name with a space and so that the user's input will be matched to the correct flavor no matter what type of capitalization is used.
Position the output so that the number of scoops for each flavor is right-aligned (assume that the demand for flavors can vary, so the number of scoops for any flavor may be between one and three digits):
Example output:
DAILY SCOOP REPORT:
Chocolate: 92
Vanilla: 103
Strawberry: 89
Mint: 8
Rocky Road: 76
Mocha: 64
I tried to use the switch statement but not sure if that is correct. Also, it wouldn't allow the return of the flavors in the count function due to them being changed int when applying the update to the count, so I tried to use the atoi() but don't really know how to use it and the tutorials I read about it don't fit my situation close enough for me to manipulate it to make it work.
I hope that I have described things enough. Here is my code thus far.
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
String count (string& flavor, string& count, string& chocolate, string& vanilla, string& strawberry, string& mint, string& rocky_road, string& mocha);
int main()
{
string stop, flavor, count = 0, chocolate, vanilla, strawberry, mint, rocky_road, mocha;
cout << "Welcome to Frozen Tongue Ice Cream Shop\n"<<endl;
cout << "Please enter the flavor of icecream sold or 'STOP' to exit.\n"<<endl;
<< "Flavors avaliable:\n"<<endl;
<< "chocolate\n"<<endl;
<< "valnilla\n"<<endl;
<< "strawberry\n"<<endl;
<< "mint\n"<<endl;
<< "rocky road\n"<<endl;
<< "mocha\n"<<endl;
<< "Enter flavor : ";
cin.getline >> flavor;
cout <<"Now enter number of scoops sold\n"<<endl;
cin >> count;
if (flavor = 'STOP' || 'stop')
{
cout<<"You have chosen to exit the program. Thank you."<<endl;
exit(1);
}
else count ( flavor, count, chocolate, vanilla, strawberry, mint, rocky_road, mocha);
cout << "\nDAILY SCOOP REPORT: \n"<<endl;
<< "chocolate :"<<chocolate<<"\n"<<endl;
<< "vanilla :"<<vanilla<<"\n"<<endl;
<< "strawberry :"<<strawberry<<"\n"<<endl;
<< "mint :"<<mint<<"\n"<<endl;
<< "rocky road :"<<rocky_road<<"\n"<<endl;
<< "mocha :"<<mocha<<"\n"<<endl;
return 0;
}
String count (string& flavor, string& count, string& chocolate, string& vanilla, string& strawberry, string& mint, string& rocky_road, string& mocha)
{
string choc, van, str, mt, rrd, mch;
chocolate = choc;
vanilla = van;
strawberry = str;
mint = mt;
rocky_road = rrd;
mocha = mch;
switch (count)
{
case 'choc' :
chocolate = count;
break;
case 'van':
vanilla = count;
break;
case 'str':
strawberry = count;
break;
case 'mt':
mint = count;
break;
case 'rrd':
rocky_road = count;
break;
case 'mch':
mocha = count;
break;
default:
cout<<"You have entered an unavaliable flavor. The program will now end."<<endl;
exit(1);
}
cout << atoi(count ())
return chocolate, vanilla, strawberry, mint, rocky_road, mocha;
}
Thanks in advance for any assistance.