Convert following flowchart in to C++ Code
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{ //variables
bool orderburger=true;
char fries;
char drink;
string
bill2="Drink = 30Rs";
string
bill="Burger = 50Rs\n";
cout<<"\t\t\t\tOrder burger"<<endl;
//Fries
cout<<"Want Fries?
(if want enter y otherwise press n)"<<endl;
cin>>fries;
if(fries=='y')
{
cout<<"fries are orded"<<endl;
bill="\t Burger = 50Rs\n\t Fries = 30Rs\n\t ";
}
else {if(fries=='n')
{
cout<<"fries are not orded"<<endl;
}
else cout<<"wrong
input"<<endl;
}
//Drink
cout<<"Want Drink?
(if want enter y otherwise press n)"<<endl;
cin>>drink;
if(drink=='y')
{
cout<<"drink is orded"<<endl;
bill=bill+bill2;
}
else {if(drink=='n')
{
cout<<"drink is not orded"<<endl;
}
else cout<<"wrong
input"<<endl;
}
//calculation of bill
cout<<"\n\t
Bill"<<endl;
cout<<bill<<endl;
cout<<"Pay it to cashier."<<endl;
system("pause");
return 0;
}
Output:
Comments
Post a Comment