#include <iostream> #include <iomanip> #include<string.h> using namespace std; //global speed variable float speed=80.0; //Function to search index of destination //by name int SearchDestination(char Destination[5][15]) { char Dst[15]; cout<<"\nEnter Destination name:"; cin>>Dst; int i; for(i=0;i<5;i++) { //Loop will break and function will return index //if search is successful if (strcmp(Destination[i],Dst) == 0) return (i+1); } //if search is unsuccessful it will return -1 return -1; } //Function to display details of destination void DisplayDetails(char Destination[5][15],float Details[5][2],int index) { float time; cout<<"\n"; cout << setw(25) << left <<"Destination"; cout<<setw(5)<<" "; cout="" <<="" setw(25)="" left="" <<"distance="" (km)"; cout<<setw(5)<<"="" <<"fare(rm)"; cout<<"\n"; cout="" <<destination[index]; cout<<setw(5)<<"="" <<details[index][0]; cout<<setw(5)<<"="" <<details[index][1]; ="" time="" will="" be="" calculated="" in="" mins time="(Details[index][0]/speed)*60; cout<<"\nYou" reach="" your="" destination="" "<<time<<"="" minutes."; } int="" main() { char="" destination[5][15]="{"Setiawangsa","Bangsar","Masjid" jamek","subang="" jaya","kelana="" jaya"}; float="" details[5][2]="{{40,3.50}, {4,1.20}, {16,2.00}, {16,1.80}, {32,3.00}}; int" index; char="" ch="y" ; ="" it="" run="" and="" ask="" for="" input="" till="" user="" press="" y="" or="" y do { cout<<"\nenter="" the="" destination:"; cin="">>index; DisplayDetails(Destination,Details,index-1); cout<<"\n"; cout<<"\nDo you want to continue? "; cin>>ch; }while(ch=='Y'||ch=='y'); cout<<"\nThank you"; return 0; }
Quote:have tried to convert it...but it say error...help me
C++ I/O
C
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)