urgent! plz help
-
hi...could anyone check the codings below? thanks. #include #include using namespace std; class Bus { int number; char startDepot[30]; char endDepot[30]; int departureTime; public: void update(); void display(); }; void Bus::update() { cout << "Enter the bus number (eg 83): "; cin >> number; cin.ignore(80, '\n'); cout << "Enter the start depot (eg Sengkang): "; cin.getline(startDepot, 30, '\n'); cout << "Enter the end depot (eg Punggol): "; cin.getline(endDepot, 30, '\n'); cout << "Enter the departure time (eg 1605): "; cin >> departureTime; cin.ignore(80, '\n'); } void Bus::display() { cout << "Bus number : " << setw(3) << setfill('0') << number << endl; cout << "Start depot : " << startDepot << endl; cout << "End depot : " << endDepot << endl; cout << "Departure time : " << setw(4) << setfill('0') << departureTime << endl;; } int main() { int count; Bus *b; cout << "How many buses are there: "; cin >> count; b = new Bus[count]; char choice; int num; do { cout << "u. Update\n"; cout << "d. Display\n"; cout << "e. Exit\n"; cout << "enter selection: "; cin >> choice; switch(choice) { case 'u' : cout << "enter bus number (1-" << count << "): "; cin >> num; b[num-1].update(); break; case 'd' : cout << "enter bus number (1-" << count << "): "; cin >> num; b[num-1].display(); break; } } while (choice != 'e'); delete [] b; return 0;
-
hi...could anyone check the codings below? thanks. #include #include using namespace std; class Bus { int number; char startDepot[30]; char endDepot[30]; int departureTime; public: void update(); void display(); }; void Bus::update() { cout << "Enter the bus number (eg 83): "; cin >> number; cin.ignore(80, '\n'); cout << "Enter the start depot (eg Sengkang): "; cin.getline(startDepot, 30, '\n'); cout << "Enter the end depot (eg Punggol): "; cin.getline(endDepot, 30, '\n'); cout << "Enter the departure time (eg 1605): "; cin >> departureTime; cin.ignore(80, '\n'); } void Bus::display() { cout << "Bus number : " << setw(3) << setfill('0') << number << endl; cout << "Start depot : " << startDepot << endl; cout << "End depot : " << endDepot << endl; cout << "Departure time : " << setw(4) << setfill('0') << departureTime << endl;; } int main() { int count; Bus *b; cout << "How many buses are there: "; cin >> count; b = new Bus[count]; char choice; int num; do { cout << "u. Update\n"; cout << "d. Display\n"; cout << "e. Exit\n"; cout << "enter selection: "; cin >> choice; switch(choice) { case 'u' : cout << "enter bus number (1-" << count << "): "; cin >> num; b[num-1].update(); break; case 'd' : cout << "enter bus number (1-" << count << "): "; cin >> num; b[num-1].display(); break; } } while (choice != 'e'); delete [] b; return 0;
-
Does it work?
-
It has very severe error that it is without comments. And believe me my friend a code without comments is just a deadbody. cheers