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

When I compile the program, i get the error message \"warning:multi-line string

ID: 3611353 • Letter: W

Question

When I compile the program, i get the error message "warning:multi-line string laterals are deprecated". what does this mean?how can i fix it? thanks!

the program reads as;


#include <iomanip>

#include <string>

#include <fstream>

#include <iostream>

using namespace std;

// Structure Declaration

struct menuitemtype

{

string menuitem[10];

float menuprice[10];

};

// Function Prototype Declaration

void getdata(menuitemtype &m,int &c);

void showmenu();

void printcheck(menuitemtype &m,int c);

int main()

{

// Start main

menuitemtype menulist;

int c;

showmenu();

getdata(menulist,c);
printcheck(menulist, c);
// System Pause

system ("pause");

} // end fuction

// Function Definitions

void showmenu()

{

cout << "WELCOME TO CHRIS'S RESTAURAUNT" << endl<< endl;

cout << "Please Select An Item Or Two From Our Menu" <<endl << endl;

cout << "1. Plain Egg" << " " << "1.45"<< endl << endl;

cout << "2. Bacon & Egg" << " " << "2.45"<< endl << endl;

cout << "3. Muffin" << " " << "0.99" <<endl << endl;

cout << "4. French Toast" << " " << "1.99"<< endl << endl;

cout << "5. Fruit Basket" << " " << "2.49"<< endl << endl;

cout << "6. Cereal" << " " << "0.69" <<endl << endl;

cout << "7. Coffee" << " " << "0.50" <<endl << endl;

cout << "8. Tea" << " " << "0.75" <<endl << endl;

} // end of show menu

void getdata(menuitemtype &m ,int &c)

{

int k;

int choice;

cout << "Enter The Total Number Of Items Selected By TheCustomer: " << endl;

cin >> c;

                                                                                      

// For Loop

for(k=0;k<c;k++)

{cout << "Enter The Item Selected: " << endl;

cin >> choice;  

switch(choice)

{

case 1:m.menuitem[k]="Plain Egg";

m.menuprice[k]=1.45;

break;

case 2:m.menuitem[k]="Bacon & Egg";

m.menuprice[k]=2.45;

break;

case 3:m.menuitem[k]="Muffin";

m.menuprice[k]=0.99;

break;

case 4:m.menuitem[k]="French Toast";

m.menuprice[k]=1.99;

break;

case 5:m.menuitem[k]="Fruit Basket";

m.menuprice[k]=2.49;

break;

case 6:m.menuitem[k]="Cereal";

m.menuprice[k]=0.69;

break;

case 7:m.menuitem[k]="Coffee";

m.menuprice[k]=0.50;

break;

case 8:m.menuitem[k]="Tea";

m.menuprice[k]=0.75;

break;

}

}// end for

} // end getdata

void printcheck(menuitemtype &m, int c)

{

int j;

float price=0.0,tax=0.00,total,taxrate=.08;
cout<<endl;
for(j=0;j<c;j++)
  {cout<<left<<setw(15)<<m.menuitem[j]<<setprecision(2)<<left<<fixed<<"$"<<m.menuprice[j]<<endl;
   total+=m.menuprice[j];
   }
tax=total*taxrate;
total+=tax;
cout<<left<<setw(15)<<"tax"<<setprecision(2)<<left<<fixed<<"$"<<tax<<endl;
cout<<left<<setw(15)<<"AmountDue"<<"$"<<left<<setprecision(2)<<fixed<<total<<endl;
return;
}

Explanation / Answer

Dear User, What compiler are you using in the first place? I have run the codein Dev-C++ and Visual Studio and did not get the error that youhave received. However I did realize a couple other things... A) You do not initialize total in your printcheck method, and youadd to it in the code and this will cause a serious error B) You do not have a default case in your switch statement which,depending on the compiler, could give you really funky results ifsomeone selects an item not on the list. C) The only warnings i get when I run your code is that it isconverting a double to a float, which is no big deal but if youdon't like seeing any warnings, you can do a simple cast whichwould look as follows.... floatprice=(float)0.0,tax=(float)0.00,total= (float)0.00,taxrate=(float).08;// Everything in bold is what should be added, and i added thetotal = 0.00 because it needs to be initialized. If you would like to use a different C++ compiler but don't want topay for one, I highly recommend using Bloodshed Dev-C++, it is freejust google search and you'll find it Hope this helps!

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