this is my program and i want 2 put it in terms of modules(functions):
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{ //initialization phase.
string month;
int day=0,cones;
char choice;
double price;
//processing phase.
while(day <= 31)//day must not be greater than 31.
{
cout<<"Welcome to The Ze_Viru$ Ice Cream Producers!!\n";
//print text
cout<<"Please enter month:";
//prompt for input.
cin>>month;
cout<<"Please enter day:";
//prompt for input.
cin>>day;
while(day >=32 )//day must not be greater than 31.
{
cout<<"Sorry,the month range from 1 to 30 or 31:not that: "<<day<<endl;
//print text.
cout<<"Please enter day:";
//prompt for input
cin>>day;
}
cout<<"The codes are as follows:\n";
//print text.
cout<<"Strawberry:\tS\nVanilla:\tV\nMixed:\tM\nApple:\tA\nYoghurt:\tY\nPlease enter only one from the above\n";
//print text.
cin>>choice;
switch(choice) {
case 'S':
case 's':
if(day >= 1 && day <= 10)
{
cout<<"You have selected the Strawberry\n";
//print text.
cout<<"How many cones would you like to have?\n";
//promt for input
cin>>cones;
price = 4.50*cones; //assignment of price.
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
//print text.
}
else if(day >= 11 && day <= 20)
{
cout<<"You have selected the Strawberry\n";
//print text.
cout<<"How many cones would you like to have?\n";
//print text.
cin>>cones;
price = 4.00*cones; //assignment of price.
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
//print text.
}
else if(day >=21 && day <= 31)
{
cout<<"You have selected the Strawberry\n";
//print text
cout<<"How many cones would you like to have?\n";
//print text.
cin>>cones;
price = 3.25*cones; //assignment of price.
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you for shopping in our store!!\n";
//print text.
}
break;
case 'V':
case 'v':
if(day >= 1 && day <=10)
{
cout<<"You have selected the Vanilla\n";
//print text.
cout<<"How many cones would you like to have?\n";
//print text.
cin>>cones;
price = 8.00*cones; //assignment of price
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
//print text.
}
else if(day >=11 && day <= 20)
{
cout<<"You have selected the Vanilla\n";
//print text.
cout<<"How many cones would you like to have?\n";
//print text
cin>>cones;
price = 7.50*cones; //assignment of price
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
//print text.
}
else if(day >=21 && day <= 31)
{
cout<<"You have selected the Vanilla\n";
//print text.
cout<<"How many cones would you like to have?\n";
//print text.
cin>>cones;
price = 6.75*cones; //assignment of price.
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
//Print text.
}
break;
case 'A':
case 'a':
if(day >=1 && day <= 10)
{
cout<<"You have selected the Apple\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 6.75*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
else if(day >=11 && day <= 20)
{
cout<<"You have selected the Apple\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 6.25*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
else if(day >=21 && day <= 31)
{
cout<<"You have selected the Apple\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 5.50*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
break;
case 'Y':
case 'y':
if(day >=1 && day <= 10)
{
cout<<"You have selected the Yoghurt\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 9.65*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
else if(day >=11 && day <= 20)
{
cout<<"You have selected the Yoghurt:\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 9.15*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
else if(day >=21 && day <= 31)
{
cout<<"You have selected the Yoghurt\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 8.40*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
break;
case 'M':
case 'm':
if(day >=1 && day <= 10)
{
cout<<"You have selected the Mixed\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 13.00*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
else if(day >=11 && day <= 20)
{
cout<<"You have selected the Mixed\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 12.50*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
else if(day >=21 && day <= 31)
{
cout<<"You have selected the Mixed\n";
cout<<"How many cones would you like to have?\n";
cin>>cones;
price = 11.85*cones;
cout<<"Amount due is :R"<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<price<<endl;
cout<<"Thank you and call again!!\n";
}
break;
default:
cout<<"You have entered the wrong code!!\n";
cout<<"Please check your spelling!\n";
break;
}
cout<<"Next customer please!!\n";
}
return 0;
}
:sad: :sad: