View the step-by-step solution to:

Objectives This assignment task is designed to test your understanding of arrays, functions, sorting and searching. Assignment specification Write a

Objectives
This assignment task is designed to test your understanding of arrays, functions, sorting and searching.
Assignment specification
Write a C++ program to randomly generate, store, sort, search and display the car price (maximum price:
K29999) owned by N students at DWU. N should be declared as a constant in your program and it should
be equal to 10. You must use a single dimension array to store the car price. Your program should display
and execute a menu with the following options. A switch statement must be used to execute the following
menu options.
1. Initialise all the elements of the array to -99
2. Randomly generate and store the car price for N students
3. Calculate and display the average price of the car owned by N students
4. Find and display the most expensive car
5. Find and display all cars below the average car price
6. Sort and display all car prices in ascending order
7. Search and display array index for a given car price
8. Exit
1. Initialise all the elements of the array to -99
This option initialises all the elements of the array to -99.
2. Randomly generate and store the car price for N students
This option generates the car price for each student using rand() function and stores it in an array. The
random car price must be less than or equal to K29999.
3. Calculate and display the average price of the car owned by N students
This option calculates and displays the average price of the car owned by N students.
4. Find and display the most expensive car
This option finds and displays the most expensive car.
5. Find and display all cars below the average car price
This option finds and displays all cars below the average price.
6. Sort and display all car prices in ascending order
This option sorts and displays all car prices in ascending order. You can use any sorting algorithm
which uses at least two for loops and one if statement.
7. Search and display array index for a given car price
This option searches and displays array index for a given car price. The program asks the user to enter
the price using the keyboard and searches for it. If the car price entered from the keyboard is found
then the program displays an array index otherwise it displays an appropriate message.
8. Exit
The program should display the message “Thanks for using this program”, your id number and exit.
4
The whole program should work in a loop to enable the user to initialise all the elements of the array to
-99, randomly generate and store the car price for N students, calculate and display the average price of
the car owned by N students, find and display the most expensive car, find and display all cars below the
average car price, sort and display all car prices in ascending order, search and display array index for a
given car price and exit.

This question was asked on May 13, 2010.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors and customizable flashcards—available anywhere, anytime.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access or to earn money with our Marketplace.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
  • -

    Flashcards

    Browse existing sets or create your own using our digital flashcard system. A simple yet effective studying tool to help you earn the grade that you want!

    Browse Flashcards