C++ Programming I would like to make this code like the result(photo submitted). And please let me know how I can open it on notepad. ----------------------------------------------------------------- Code: #include #include using namespace std; int main(); int taxi_num=5; int tx1_call=0,tx1_pass=0, tx2_call=0,tx2_pass=0, // Creating global variables tx3_call=0,tx3_pass=0, tx4_call=0,tx4_pass=0, tx5_call=0,tx5_pass=0; int total_passangers=0; // Total passanger count char NeedTaxi(){ if(taxi_num<1) taxi_num=5; char ans; cout<<"\n\nDo you need Taxi (Y/N) : "; cin>>ans; if(ans!='Y' && ans!='N') {cout<<"\n\nError entry !\n\n"; main();} if(ans=='N') return ans; cout<<"Taxi #"<
C++ Programming
I would like to make this code like the result(photo submitted).
And please let me know how I can open it on notepad.
-----------------------------------------------------------------
Code:
#include<iostream>
#include<fstream>
using namespace std;
int main();
int taxi_num=5;
int tx1_call=0,tx1_pass=0,
tx2_call=0,tx2_pass=0, // Creating global variables
tx3_call=0,tx3_pass=0,
tx4_call=0,tx4_pass=0,
tx5_call=0,tx5_pass=0;
int total_passangers=0; // Total passanger count
char NeedTaxi(){
if(taxi_num<1) taxi_num=5;
char ans;
cout<<"\n\nDo you need Taxi (Y/N) : ";
cin>>ans;
if(ans!='Y' && ans!='N') {cout<<"\n\nError entry !\n\n"; main();}
if(ans=='N') return ans;
cout<<"Taxi #"<<taxi_num<<" will pick you up in a few minutes.";
if(taxi_num==5) {tx5_call++; tx5_pass+=3;} // Add 3 passangers everytime taxi 5 called
if(taxi_num==4) {tx4_call++; tx4_pass+=5;} // Add 5 passangers everytime taxi 4 called
if(taxi_num==3) {tx3_call++; tx3_pass+=4;} // Add 4 passangers everytime taxi 3 called
if(taxi_num==2) {tx2_call++; tx2_pass+=2;} // Add 2 passangers everytime taxi 2 called
if(taxi_num==1) {tx1_call++; tx1_pass+=3;} // Add 3 passangers everytime taxi 1 called
taxi_num--;
return ans;
}
int main(){
ofstream f("filename.txt");
cout<<"********* Welcome to ABC Taxi *********";
while(NeedTaxi()=='Y'){ NeedTaxi();}
total_passangers+=tx1_pass+tx2_pass+tx3_pass+tx4_pass+tx5_pass;
//Writing the data to the file
f<<"ABC Taxi served a total of "<<total_passangers<<" passengers today\n\n.";
f<<"Taxi 1 Taxi 2 Taxi 3 Taxi 4 Taxi 5 Taxi6\n\n";
f<<tx1_call<<" Calls "<<tx2_call<<" Calls "<<tx3_call<<" Calls "<<tx4_call<<" Calls "<<tx5_call<<" Calls \n\n";
f<<tx1_pass<<" Passanger "<<tx2_pass<<" Passanger "<<tx3_pass<<" Passanger "<<tx4_pass<<" Passanger "<<tx5_pass<<" Passanger \n\n";
f.close();
}
----------------------



Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









