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. plz ans this program

plz ans this program

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
4 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
    Member_14779305
    wrote on last edited by
    #1

    Write and test the following function that attempts to remove all occurrences of an item from an array:
    intremove(int a[], int& n, int x)
    The function searches the first n elements of the array a for the item x. If an x is found, it is removed, all the elements above that position are shifted down, the
    array size n is decremented. This is repeated until all occurrences of x in the array are removed and then the total number of elements removed is returned. If x is not
    .Write your own Car class. The class data should include:
    I. make (using an array of char),
    II. year,
    III. petrol,
    IV. tankSize,
    V. mpg (miles per gallon),
    VI. owner (using an array of char).
    The functions should include:
    I. display,
    II. fillPetrol: pass number of gallons as a parameter and return gallons actually input (before full),
    III. drive: pass distance as a parameter and return distance actually travelled (stopping if empty),
    IV. changeOwner (passing new name as a parameter).
    V. You should also have two constructors (one with and one without parameters) and any other functions needed, such as full() and empty(). (Should these 2 functions be public or private?)
    VI. Put code in the constructors to show when each is called (cout<< “Constructor X called”;).
    VII. Write a program to create and use a Car object, making sure it calls all the public functions.

    L V D 3 Replies Last reply
    0
    • M Member_14779305

      Write and test the following function that attempts to remove all occurrences of an item from an array:
      intremove(int a[], int& n, int x)
      The function searches the first n elements of the array a for the item x. If an x is found, it is removed, all the elements above that position are shifted down, the
      array size n is decremented. This is repeated until all occurrences of x in the array are removed and then the total number of elements removed is returned. If x is not
      .Write your own Car class. The class data should include:
      I. make (using an array of char),
      II. year,
      III. petrol,
      IV. tankSize,
      V. mpg (miles per gallon),
      VI. owner (using an array of char).
      The functions should include:
      I. display,
      II. fillPetrol: pass number of gallons as a parameter and return gallons actually input (before full),
      III. drive: pass distance as a parameter and return distance actually travelled (stopping if empty),
      IV. changeOwner (passing new name as a parameter).
      V. You should also have two constructors (one with and one without parameters) and any other functions needed, such as full() and empty(). (Should these 2 functions be public or private?)
      VI. Put code in the constructors to show when each is called (cout<< “Constructor X called”;).
      VII. Write a program to create and use a Car object, making sure it calls all the public functions.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      We are happy to help people who have problems with code that they have written. However, we are not here to do their homework. Homework assignments are provided in order to test your knowledge, so it would not help you to be assessed on someone else's work. Give it a try, it may not be as difficult as you think.

      1 Reply Last reply
      0
      • M Member_14779305

        Write and test the following function that attempts to remove all occurrences of an item from an array:
        intremove(int a[], int& n, int x)
        The function searches the first n elements of the array a for the item x. If an x is found, it is removed, all the elements above that position are shifted down, the
        array size n is decremented. This is repeated until all occurrences of x in the array are removed and then the total number of elements removed is returned. If x is not
        .Write your own Car class. The class data should include:
        I. make (using an array of char),
        II. year,
        III. petrol,
        IV. tankSize,
        V. mpg (miles per gallon),
        VI. owner (using an array of char).
        The functions should include:
        I. display,
        II. fillPetrol: pass number of gallons as a parameter and return gallons actually input (before full),
        III. drive: pass distance as a parameter and return distance actually travelled (stopping if empty),
        IV. changeOwner (passing new name as a parameter).
        V. You should also have two constructors (one with and one without parameters) and any other functions needed, such as full() and empty(). (Should these 2 functions be public or private?)
        VI. Put code in the constructors to show when each is called (cout<< “Constructor X called”;).
        VII. Write a program to create and use a Car object, making sure it calls all the public functions.

        V Offline
        V Offline
        Victor Nijegorodov
        wrote on last edited by
        #3

        I agree with Richard. Here is a very good opinion regarding the homework: [Visual C++ General: Can you help me with my homework assignment?](http://forums.codeguru.com/showthread.php?366302-Visual-C-General-Can-you-help-me-with-my-homework-assignment&p=1279572&highlight=homework#post1279572)

        1 Reply Last reply
        0
        • M Member_14779305

          Write and test the following function that attempts to remove all occurrences of an item from an array:
          intremove(int a[], int& n, int x)
          The function searches the first n elements of the array a for the item x. If an x is found, it is removed, all the elements above that position are shifted down, the
          array size n is decremented. This is repeated until all occurrences of x in the array are removed and then the total number of elements removed is returned. If x is not
          .Write your own Car class. The class data should include:
          I. make (using an array of char),
          II. year,
          III. petrol,
          IV. tankSize,
          V. mpg (miles per gallon),
          VI. owner (using an array of char).
          The functions should include:
          I. display,
          II. fillPetrol: pass number of gallons as a parameter and return gallons actually input (before full),
          III. drive: pass distance as a parameter and return distance actually travelled (stopping if empty),
          IV. changeOwner (passing new name as a parameter).
          V. You should also have two constructors (one with and one without parameters) and any other functions needed, such as full() and empty(). (Should these 2 functions be public or private?)
          VI. Put code in the constructors to show when each is called (cout<< “Constructor X called”;).
          VII. Write a program to create and use a Car object, making sure it calls all the public functions.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          It's all done. I even went so far as to grade it for you. Definitely a solid B. How would you like it delivered? :rolleyes:

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          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