Make an algorithm of this C++ code #include #include #include using namespace std; int main() { char fname[50], lname[50], phonenum [15], pname[50]; int opt, n, x, qty, num, cont=1, month, day, year; while(cont==1) { cout<<"============================================================================"<>n; switch (n) { case 1: system("cls"); { cout<<"Please enter buyer's First name: "<"; cin>>fname; cout<"; cin>>lname; cout<>month; cout<<"Day (DD): "; cin>>day; cout<<"Year (YYYY): "; cin>>year; cout<>phonenum; cout<>x; system("cls"); string pname[x]; float price[x], qty[x], total=0; for(int i=0; i>pname[i]; cout<>qty[i]; cout<>price[i]; cout<>cont; cout<
Make an
#include <iostream> #include <string.h> #include <stdlib.h>
using namespace std;
int main() { char fname[50], lname[50], phonenum [15], pname[50]; int opt, n, x, qty, num, cont=1, month, day, year;
while(cont==1) {
cout<<"============================================================================"<<endl; cout<<" RECEIPT MAKER"<<endl; cout<<"============================================================================"<<endl<<endl; cout<<"To start, please choose one"<<endl<<endl; cout<<"1. Make receipt"<<endl; cout<<"2. Exit"<<endl; cout<<"============================================================================"<<endl<<endl; cout<<"Please enter the number of chosen process: "<<endl<<endl; cin>>n;
switch (n) { case 1: system("cls"); { cout<<"Please enter buyer's First name: "<<endl; cout<<"-->"; cin>>fname; cout<<endl;
cout<<"Please enter buyer's Last name: "<<endl; cout<<"-->"; cin>>lname; cout<<endl;
cout<<"Date of Purchase"<<endl; cout<<"Month(MM): "; cin>>month; cout<<"Day (DD): "; cin>>day; cout<<"Year (YYYY): "; cin>>year; cout<<endl;
cout<<"Phone Number: "; cin>>phonenum; cout<<endl;
cout<<"How many orders do you wish to input?"<<endl; cin>>x; system("cls"); string pname[x]; float price[x], qty[x], total=0; for(int i=0; i<x; i++) { cout<<"Enter product code of item #"<<i+1<<" :"<<endl; cin>>pname[i]; cout<<endl;
cout<<"Quantity"<<endl; cin>>qty[i]; cout<<endl;
cout<<"Price"<<endl; cin>>price[i]; cout<<endl; }
for(int j=0; j<x; j++) { total+=(price[j]*qty[j]); } system("cls"); cout<<"============================================================================"<<endl; cout<<" RECEIPT"<<endl; cout<<"============================================================================"<<endl<<endl; cout<<"Name of Buyer: "<<fname<<" "<<lname; cout<<endl; cout<<"Date of Purchase (MM/DD/YYYY): "<<month<<" "<<day<<" "<<year<<endl; cout<<"Product code: "<<"\t Quantity: "<<"\t Price: "<<endl; for(int i=0; i<x; i++) { cout<<pname[i]<<"\t\t"<<qty[i]<<"\t\t"<<price[i]<<endl; } cout<<"============================================================================"<<endl; cout<<"Total Amount: "<<"\t\t\t\t"<<total<<endl<<endl<<endl;
break; } case 2: { system("cls"); cout<<endl<<"Thank you for using this break; } default: { cout<<endl<<"Please enter 1 and 2 only"<<endl; break; } } cout<<"Do you want to make another receipt? ['1' = yes or '0' = no]: "; cin>>cont; cout<<endl; system("cls"); } return 0; }
|
Step by step
Solved in 2 steps