473,695 Members | 3,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two-dimensional arrays

2 New Member
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 calculateAveNoi seLevelPerSpeed 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 calculateAveNoi seLevelPerCar 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 calculateOveral lAveNoiseLevel 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 enterNoiseLevel Data 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 setCarManufactu rerData 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 doNoiseLevelCal culations 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 3884
sicarie
4,677 Recognized Expert Moderator Specialist
nelly0-

Please check your PM's located in the top right corner of the page.
Aug 27 '07 #2
JosAH
11,448 Recognized Expert MVP
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 New Member
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 calculateAveNoi seLevelPerSpeed 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 Recognized Expert Moderator Specialist
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 Recognized Expert Moderator Specialist
In that case your return type on the calculateAveNoi seLevelPerSpeed 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
1780
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. Inside (or just after) the same query that searches for available seats, I need to SIMULTANEOUSLY mark those seats as "on hold". I've only read about, but not yet used MySQL transactions, and wonder if this simultaneous "search-and-hold"...
8
1744
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). TABLE matchResults cont_id team_id contest_result 1 1 3 1 2 5
6
1875
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
9351
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 record in the second table and call the update method of the data adapter the command builders update command text is for the first table. Can the command builder handle two tables? Code example: Dim oCOnn As New SqlConnection("Data Source=.;" &...
6
4078
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 the user can change the date, which will force a requery in the subform to bring up records from the date selected. My question is this... The query in the subform is a very simple one, with only three fields being returned. In the interest of...
7
12888
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 compare these two objects so that it will return true if both object's members have the same value... it is good if u can give me a single function or simple code snippet.. Thank U -- Peter...
0
1689
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 became realllllllllllly slow. Content in LoginView Role Groups was not displaying even after a user in a role had logged in. It was taking about 15 seconds or so for the login control to display when the login link was selected on the homepage....
9
5262
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 w1 and w2 make up the first string and, w3 and w4 make up the second string. I do not want to allocate memory, then put the words together to create a string only to facilitate strcmp() comparison. My question; Does anyone know how to get the...
9
2018
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 million times, but I can't seem to find the answer. For example, I have two classes stored in separate files as such. File: one.py ======== class One:
0
8640
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9122
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9001
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7672
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4348
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3018
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2281
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.