468,101 Members | 1,315 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,101 developers. It's quick & easy.

Two-dimensional arrays

2
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six different models of cars that are produced by the car manufacturer.

Task 1

Step 1: Create a directory called Assignment02 and create the files of steps 2, 3 and 4 in this directory as well as your project file.
Step 2: Create a file called NoiseLevels.cpp.
Step 3: Create a file called CarManufacturer.cpp.
Step 4: Create a file called MainMenu.cpp.
Step 5: Create a file called Run.cpp.


NoiseLevels.cpp

You must write a class called NoiseLevels and save it in a file called NoiseLevels.cpp.

The general purpose of this class is to calculate average noise levels.

This class must:
• Be a back-end class.
• Have a data member of a one-dimensional array to hold the seven different speeds at where the noise levels are recorded (See Fig. 2).
• Have a data member of a two-dimensional array that can store, for a maximum of 6 models of cars, the noise levels at the 7 different speeds stored in the first array (See Fig. 2).
• Have a constructor that will set the seven different speeds of the one-dimensional array to those appearing in Fig.2 below, and set all the two-dimensional array’s values to zeroes.
• Have a member function called setNoiseLevels that will receive two parameters: an integer value representing the number of the car model whose noise levels must be set, and a one-dimensional array that is used to set the 7 noise levels for that car model.
• Have a member function called calculateAveNoiseLevelPerSpeed that will return a one-dimensional array that will hold the calculated average noise level for each of the 7 speeds at which it was measured, for all cars that contain noise levels. The function should receive an integer value indicating the number of car models whose noise levels are stored in the two-dimensional array.
• Have a member function called calculateAveNoiseLevelPerCar that will return a one-dimensional array that will hold the calculated average noise level for that specific car, for the 7 speeds at which it was measured. The function should receive an integer value indicating the number of car models whose noise levels are stored in the two-dimensional array.
• Have a member function called calculateOverallAveNoiseLevel that will return the overall average noise level, receiving integer value indicating the number of car models whose noise levels are stored in the two-dimensional array.
• NOT have any additional methods besides the ones specified in this question.



Car Speed(km/h)
20 30 40 50 60 70 80
1 88 90 94 102 111 122 134
2 75 77 80 86 94 103 113
3 80 83 85 94 100 111 121
4 68 71 76 85 96 110 125
5 77 84 91 98 105 112 119
6 81 85 90 96 102 109 120

Fig. 2: An EXAMPLE of the Data for the Two-Dimensional Array

CarManufacturer.cpp

You must write a class called CarManufacturer and save it in a file called CarManufacturer.cpp.

The general purpose of this class is to represent the data pertaining to a specific car manufacturer, with emphasis on the storage and calculation of noise levels for various models.

This class must:
• Be a front-end class.
• Contain code that will prevent CarManufacturer.cpp file to be defined twice.
• Must contain a character array to hold the name of the car manufacturer.
• Must hold an integer value to store the number of models that the car manufacturer produces.
• Hold a one-dimensional array of strings, of size 6, to store the names of the models.
• Hold an object of type NoiseLevels to hold the noise levels for the number of car models the car manufacturer produces.
• Have a private member function called enterNoiseLevelData that receives the an integer model number and will prompt for and read the noise levels for that car model into a one-dimensional array and set these values in the object of type NoiseLevels.
• Have a public member function called setCarManufacturerData that will enable the end-user to interactively set the name of the car manufacturer, the number of models that the manufacturer produces, the names for these models, as well as noise level data.
• Have a private member function called displayResult that receives a floating point array and the number of elements in the array, and display the values stored in the array.
• Have a member function called doNoiseLevelCalculations that will display the following menu, and execute the correct member functions based on the option selected, displaying the result:


=======NOISE LEVEL CALCULATIONS=======

1. Calculate Average Noise Level per Car Model
2. Calculate Average Noise Level per Speed
3. Calculate Overall Noise Level Average
4. Exit

Please select an option

Fig. 3
This menu must enable the end-user to execute the different menu options. This menu must also be displayed until option 4 is selected.
If the user enters the wrong number the program must display a message informing the end-user that the entered number is not a valid option and display the menu again.
• NOT have any additional methods besides the ones specified in this question.

MainMenu.cpp

You must write a class called MainMenu and save it in a file called MainMenu.cpp.

The general purpose of this class is to display a menu.

This class must:
• Be a front-end class.
• Only have one public member function called showMenu() that will display a menu as follows:


=======MAIN MENU=======

1. Enter Car Manufacturer Data
2. Calculate Noise Level Averages
3. Exit

Please select an option

Fig. 1
This menu must enable the end-user to execute the different menu options. This menu must also be displayed until option 4 is selected.
Options 1 to 2 must make use of the classes below to execute the options. If the user enters the wrong number the program must display a message informing the end-user that the entered number is not a valid option and display the menu again.



Run.cpp

You must write a main program and save it in a file called Run.cpp.

The general purpose of this program is to supply the end-user with a menu that will enable him/her with the ability to specify the car manufacturer data, and to determine averages on the noise levels entered.

Main must start the MainMenu class.
Aug 27 '07 #1
5 3413
sicarie
4,677 Expert Mod 4TB
nelly0-

Please check your PM's located in the top right corner of the page.
Aug 27 '07 #2
JosAH
11,448 Expert 8TB
developing a program that will manipulate noise levels
Good; what have you got so far? Or did you just copy and paste the assignment text?
A bit more detailed: what is the problem you're struggling with?

kind regards,

Jos
Aug 27 '07 #3
nelly0
2
Hi.

I wrote the following answer about the Noise Level Section :




Expand|Select|Wrap|Line Numbers
  1.  
  2. void NoiseLevels :: setNoiseLevels(int CarNo,int carmodel[])
  3. {
  4.         CarNo = 6;
  5.  
  6.         carmodel[0]=20;
  7.         carmodel[1]=30;
  8.         carmodel[2]=40;
  9.         carmodel[3]=50;
  10.         carmodel[4]=60;
  11.         carmodel[5]=70;
  12.         carmodel[6]=80;
  13.  
  14. }
  15.  double NoiseLevels :: calculateAveNoiseLevelPerSpeed(int CarNo)
  16.  {
  17.  
  18. double Avg;
  19.  for (int cols=0 ; cols <numcols ; cols++)
  20.  {
  21.  int total;
  22.    for (int rows=0 ; rows <numrows ; rows++)
  23.    {
  24.     total = total +  CarModel[numrows][numcols];
  25.  
  26.  
  27.    int total4cols = 0;
  28.    total4cols = total4cols + CarModel[numrows][numcols];
  29.    cout<<"  "<<total4cols;
  30.    }
  31.   Avg = total / numrows;
  32.  }
  33.  
  34.  cout<<" Average of each car noise level at each speed is =  "<<Avg<<endl;
  35.  
  36.   return Avg;
  37.  }
  38.  
  39.  

Help me with the
BOLD LINES .



Class NoiseLevels

This class must:
• Be a back-end class.

• Have a member function called setNoiseLevels that will receive two parameters: an integer value representing the number of the car model whose noise levels must be set, and a one-dimensional array that is used to set the 7 noise levels for that car model.
• Have a member function called calculateAveNoiseLevelPerSpeed that will return a one-dimensional array that will hold the calculated average noise level for each of the 7 speeds at which it was measured, for all cars that contain noise levels. The function should receive an integer value indicating the number of car models whose noise levels are stored in the two-dimensional array.
Aug 28 '07 #4
sicarie
4,677 Expert Mod 4TB
nelly0-

I have already warned you about the Posting Guidelines, and you post again without code tags, not asking a specific question, posting full code, copying and pasting your homework...

You are responsible for reading the entirety of the Posting Guidelines and following them.

This is your last warning before action (as laid out in the Posting Guidelines) is taken.
Aug 28 '07 #5
sicarie
4,677 Expert Mod 4TB
In that case your return type on the calculateAveNoiseLevelPerSpeed is incorrect, it should not be a double.

On your first array - what is it that you need help with? You have the correct prototype. Let me ask you, what do you do with the CarNo variable? What does that represent, according to your explanation?

Also, you have the array of cars, how do you access the noise variable inside the car?
Aug 28 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by John Grenier | last post: by
7 posts views Thread by Prabhudhas Peter | last post: by
9 posts views Thread by dhable | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.