473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 3854
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

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

Similar topics

0
by: SimonC | last post by:
I'm looking to do something similar to a feature found on Ticketmaster.com, where you select your seats at a venue, and then you have two minutes in which to take or leave them. QUESTION 1a....
8
by: John Grenier | last post by:
Hi, I have to determine the "standing" (WIN - TIE - LOSS) from confrontations between two teams on a contest. The table matchResults has fields cont_id, team_id and contest_result (int). ...
6
by: Willem | last post by:
Hi, I have a newbie question: is it possible to make a search form in asp that searches in two different databases (access)? Willem
10
by: Hank1234 | last post by:
Can I use one Data Adapter and one Command Builder to update amny tables? Currently in my data adapter I query two tables and fill them into two tables in a data set. When I make a change to a...
6
by: Matt K. | last post by:
Hi there, I have a form in an Access project that contains a subform which displays the results of a query of the style "select * from where = #a certain date#". In the main part of the form...
7
by: Prabhudhas Peter | last post by:
I have two object instances of a same class... and i assigned values in both object instances (or the values can be taken from databse and assigned to the members of the objects)... Now i want to...
0
by: clintonG | last post by:
I applied aspnet_regsql to SQL2K which was working fine throughout Beta 2 development. After installing Visual Studio and SQL Express RTM my application has blown up. Logging in to the application...
9
by: Steven | last post by:
Hello, I have a question about strcmp(). I have four words, who need to be compared if it were two strings. I tried adding the comparison values like '(strcmp(w1, w2) + strcmp(w3, w4))', where...
9
by: dhable | last post by:
I just started working with Python and ran into an annoyance. Is there a way to avoid having to use the "from xxx import yyy" syntax from files in the same directory? I'm sure it's been asked a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.