Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with this coding. A Ice cream store sales ice cream in 3 sizes of cups

ID: 3912667 • Letter: N

Question

Need help with this coding.

A Ice cream store sales ice cream in 3 sizes of cups, small, medium and large. Cup Size Small cup $4.29 Medium $5.89 Large UNIT PRICE $6.49 Write an application for an Ice Cream shop that allow users to do following tasks. After finishing a task, display the menu again to allow users to continue to select other task until they select exit: ICE CREAM STORE 1. Sale Ice Cream 2. Total sale Ice cream today 3. Total sale ice cream in the month 0. EXIT TASK1: SALE ICE CREAM For each time sale Ice Cream, the application do the following Display the menu to allow users select the size of cup, then enter the number of cups to sale. -Users can continue select other size of cups until users select DONE SALE ICE CREAM 1. Small cup 2. Medium cup 3. Large cup 0. DONE Print out the receipt in the following format: ECEIPT SALE ICE CREAM ate: 83/18/18 mall: edium: arge 8.6 11.B 6.5 ax (8.25%): otal: 26.9 2.2 29.1

Explanation / Answer

Screenshot

------------------------------------------------------------------------------------------

Program

//Header files for I/O,precision,time and manipulation
#include <iostream>
#include <ctime>
#include<string>
#include<iomanip>
#include<fstream>
#include<cstdlib>
using namespace std;
//Function prototype
void MainMenu();
void SideMenu();
int main()
{
   //Variable for file read
   ifstream in;
   //Extract month for read file
   string mon,dateVal;
   //Read month sale details and calculation
   int s, m, l,totalS=0, totalM = 0, totalL = 0;
   //Input read
   int ch, s_ch, num = 0;

//date extraction
   string str1 = "";
   string str2 = "";
   string str3 = "";
   //Todays date extraction
   time_t rawtime;
   struct tm * timeinfo;
   char fileStore;
   char buffer[80];
   time(&rawtime);
   timeinfo = localtime(&rawtime);
   strftime(buffer, sizeof(buffer), "%d/%m/%Y", timeinfo);
   std::string str(buffer);
   //for each case different cup size calculations
   int sOrderDay = 0, mOrderDay = 0, lOrderDay = 0;
   double sOrderDayPrice = 0, mOrderDayPrice = 0, lOrderDayPrice = 0;
   int sOrder=0,mOrder=0,lOrder=0;
   double sOrderPrice = 0, mOrderPrice = 0, lOrderPrice = 0;
   //Call First screen menu
   MainMenu();
   cout << "Please enter you choice: ";
   cin >> ch;
   //loop check the user option
   while (ch == 0 || ch < 4) {
       switch (ch)
       {
           //If request for sale
       case 1:
           SideMenu();
           //prompt size of cup
           cout << "Please enter the size of cup: ";
           cin >>s_ch;
           //According to choice llop calculation and display
           while (s_ch == 0 || s_ch < 4) {
               //If choice 0 means done and display bill details
               if (s_ch == 0) {
                   cout << "RECEIPT SALE ICE CREAM" << endl;
                   cout << "Date: " << str << endl;
                   cout << "Small:          " << sOrder << "    " << sOrderPrice << endl;
                   cout << "Medium:         " << mOrder << "    " << mOrderPrice<< endl;
                   cout << "Large:          " << lOrder << "    " << lOrderPrice << endl;
                   cout << "-------------------------------------------------------" << endl;
                   cout << "SubTotal:        " <<fixed<<setprecision(2)<< sOrderPrice + mOrderPrice + lOrderPrice << endl;
                   cout << "Tax(8.25%):      " << fixed << setprecision(2)<< (sOrderPrice + mOrderPrice + lOrderPrice)*.0825 << endl;
                   cout << "Total:           " << fixed << setprecision(2) << ((sOrderPrice + mOrderPrice + lOrderPrice) + ((sOrderPrice + mOrderPrice + lOrderPrice)*.0825)) << endl;
                   sOrderPrice = 0, mOrderPrice = 0, lOrderPrice = 0;
                   goto down;
               }
               //Select small cup based calculation
               else {
                   if (s_ch == 1) {
                       cout << "Please enter the number of small cups you need: ";
                       cin >> num;
                       sOrder+=num;
                       sOrderPrice = sOrder * 4.29;
                       sOrderDay += sOrder;
                       sOrderDayPrice = sOrderDay * 4.29;
                       SideMenu();
                       cout << "Please enter the size of cup: ";
                       cin >> s_ch;
                   }
                   //Select medium cup based calculation
                   else if (s_ch == 2) {
                       cout << "Please enter the number of medium cups you need: ";
                       cin >> num;
                       mOrder+= num;
                       mOrderPrice = mOrder * 5.89;
                        mOrderDay += mOrder;
                       mOrderDayPrice = mOrderDay * 5.89;
                       SideMenu();
                       cout << "Please enter the size of cup: ";
                       cin >> s_ch;
                   }
                   //Select large cup based calculation
                   else if (s_ch == 3) {
                       cout << "Please enter the number of medium cups you need: ";
                       cin >> num;
                       lOrder+= num;
                       lOrderPrice = lOrder * 6.49;
                       lOrderDay += lOrder;
                       lOrderDayPrice = lOrderDay * 6.49;
                       SideMenu();
                       cout << "Please enter the size of cup: ";
                       cin >> s_ch;
                   }
               }
              
           }
           //Repeat your choice
       down:
           MainMenu();
           cout << "Please enter you choice: ";
           cin >> ch;
           break;
           //If you want todays sale report
       case 2:
           //Print all details
           cout << "TOTAL SALE ICE CREAM REPORT" << endl;
           cout << "Date: " << str << endl;
           cout << "Small:          " << sOrderDay << "    " << sOrderDayPrice << endl;
           cout << "Medium:         " << mOrderDay << "    " << mOrderDayPrice << endl;
           cout << "Large:          " << lOrderDay << "    " << lOrderDayPrice << endl;
           cout << "-------------------------------------------------------" << endl;
           cout << "SubTotal:        " << fixed << setprecision(2) << sOrderDayPrice + mOrderDayPrice + lOrderDayPrice << endl;
           cout << "Tax(8.25%):      " << fixed << setprecision(2) << (sOrderDayPrice + mOrderDayPrice + lOrderDayPrice)*.0825 << endl;
           cout << "Total:           " << fixed << setprecision(2) << ((sOrderDayPrice + mOrderDayPrice + lOrderDayPrice) + ((sOrderDayPrice + mOrderDayPrice + lOrderDayPrice)*.0825)) << endl;
           //Prompt for file save
           cout << "Do you want to save the sale today to file?(Y/N): ";
           cin >> fileStore;
           //If yes then save space difference format
           if (fileStore == 'y' || fileStore == 'Y'){
               std::ofstream outfile;
               outfile.open("C:/Users/deept/Desktop/sale_0318.txt", std::ios_base::app);
               outfile << str << " " << sOrderDay << " " << mOrderDay << " " << lOrderDay << endl;
               sOrderDayPrice = 0, mOrderDayPrice = 0, lOrderDayPrice = 0;
               outfile.close();
               MainMenu();
               cout << "Please enter you choice: ";
               cin >> ch;
           }
           //otherwise prompt user for next option
           else {
               MainMenu();
               cout << "Please enter you choice: ";
               cin >> ch;
           }
           //Monthly report
       case 3:
           cout << "Which month report do you want?(MMYYYY): ";
           cin >> mon;
           //Open file
           in.open("C:/Users/deept/Desktop/sale_0318.txt");
           while (!in.eof()) {
               //Taake date from each line and split into string format the user enter and compare
               in >> dateVal;
                str1 = dateVal.substr(3, 2);
                str2=dateVal.substr(6, 4);
               str3 = str1 + str2;
               //If same then calculate
               if (str3 == mon) {
                   in >> s >> m >> l;
                   totalS += s;
                   totalM += m;
                   totalL += l;
               }
               in.close();
           }
           //Display all details
           cout << "TOTAL SALE ICE CREAM Month REPORT" << endl;
           cout << "Date: "<<str1<<"/"<<str2 << endl;
           cout << "Small:          " << totalS << "    " << fixed << setprecision(2) << totalS*4.29 << endl;
           cout << "Medium:         " << totalM << "    " << fixed << setprecision(2) << totalM *5.89<< endl;
           cout << "Large:          " << totalL << "    " << fixed << setprecision(2) << totalL*6.49 << endl;
           cout << "-------------------------------------------------------" << endl;
           cout << "SubTotal:        " << fixed << setprecision(2) << (totalS*4.29) + (totalM *5.89) + (totalL*6.49 )<< endl;
           cout << "Tax(8.25%):      " << fixed << setprecision(2) << ((totalS*4.29) + (totalM *5.89) + (totalL*6.49))*.0825 << endl;
           cout << "Total:           " << fixed << setprecision(2) << (((totalS*4.29) + (totalM *5.89) + (totalL*6.49)) + ((totalS*4.29) + (totalM *5.89) + (totalL*6.49))) << endl;
           totalS = 0, totalM = 0, totalL = 0;
           //Prompt again
           MainMenu();
           cout << "Please enter you choice: ";
           cin >> ch;
           break;
           //If exit press
       case 0:
           cout << "Thank You!!!!" << endl;
           exit(0);
           break;
       default:
           break;
       }
   }

   return 0;
}
//Main menu details
void MainMenu() {
   cout << "ICE CREAM STORE 1. Sale Ice Cream 2. Total Sale Ice Cream today 3. Total Sale Ice Cream In Month 0. Exit" << endl;
}
//Second menu details
void SideMenu() {
   cout << "ICE CREAM STORE 1. Small cup 2. Medium Cup 3. Large Cup 0. Done" << endl;
}

-------------------------------------------------------------------------

Output

ICE CREAM STORE
1. Sale Ice Cream
2. Total Sale Ice Cream today
3. Total Sale Ice Cream In Month
0. Exit
Please enter you choice: 1
ICE CREAM STORE
1. Small cup
2. Medium Cup
3. Large Cup
0. Done
Please enter the size of cup: 2
Please enter the number of medium cups you need: 2
ICE CREAM STORE
1. Small cup
2. Medium Cup
3. Large Cup
0. Done
Please enter the size of cup: 1
Please enter the number of small cups you need: 2
ICE CREAM STORE
1. Small cup
2. Medium Cup
3. Large Cup
0. Done
Please enter the size of cup: 3
Please enter the number of medium cups you need: 1
ICE CREAM STORE
1. Small cup
2. Medium Cup
3. Large Cup
0. Done
Please enter the size of cup: 0
RECEIPT SALE ICE CREAM
Date: 12/07/2018
Small:          2    8.58
Medium:         2    11.78
Large:          1    6.49
-------------------------------------------------------
SubTotal:        26.85
Tax(8.25%):      2.22
Total:           29.07
ICE CREAM STORE
1. Sale Ice Cream
2. Total Sale Ice Cream today
3. Total Sale Ice Cream In Month
0. Exit
Please enter you choice: 2
TOTAL SALE ICE CREAM REPORT
Date: 12/07/2018
Small:          2    8.58
Medium:         2    11.78
Large:          1    6.49
-------------------------------------------------------
SubTotal:        26.85
Tax(8.25%):      2.22
Total:           29.07
Do you want to save the sale today to file?(Y/N): y
ICE CREAM STORE
1. Sale Ice Cream
2. Total Sale Ice Cream today
3. Total Sale Ice Cream In Month
0. Exit
Please enter you choice: 3
Which month report do you want?(MMYYYY): 072018
TOTAL SALE ICE CREAM Month REPORT
Date: 07/2018
Small:          4    17.16
Medium:         4    23.56
Large:          2    12.98
-------------------------------------------------------
SubTotal:        53.70
Tax(8.25%):      4.43
Total:           107.40
ICE CREAM STORE
1. Sale Ice Cream
2. Total Sale Ice Cream today
3. Total Sale Ice Cream In Month
0. Exit
Please enter you choice: 0
Thank You!!!!
Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote