Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. urgent! plz help

urgent! plz help

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mayVB6
    wrote on last edited by
    #1

    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;

    T 1 Reply Last reply
    0
    • M mayVB6

      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;

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      so...????? what is your question ?


      TOXCCT >>> GEII power

      M 1 Reply Last reply
      0
      • T toxcct

        so...????? what is your question ?


        TOXCCT >>> GEII power

        M Offline
        M Offline
        mayVB6
        wrote on last edited by
        #3

        does the coding looks logical?

        V S 2 Replies Last reply
        0
        • M mayVB6

          does the coding looks logical?

          V Offline
          V Offline
          vcplusplus
          wrote on last edited by
          #4

          Does it work?

          1 Reply Last reply
          0
          • M mayVB6

            does the coding looks logical?

            S Offline
            S Offline
            SiddharthAtw
            wrote on last edited by
            #5

            It has very severe error that it is without comments. And believe me my friend a code without comments is just a deadbody. cheers

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups