(a) Identify the errors in the following code and correct them to produce the output shown in the given sample. You must include comments in your code submission to indicate the error line that was corrected. #include using namespace std; class Singer { string pitch, loudness, timbre; public: Singer () { pitch = 155.; loudness = 60.; timbre = "Tenor"; %3D } Singer (float p) { pitch = p; loudness = 1; timbre = t; } void setVocal(float p, float 1, string t) { pitch = p; loudness = 1; timbre = t; } float getPitch() { float getloud() { string getTimbre() { void display() { return pitch; } return loudness; } return timbre; } cout<<"\n---- --\n"; cout<<"Singer Stats\n"; cout<<". --- \n"; cout<<"Pitch\t: "«loudness<«" Hz"<

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question

c++

 

(a) Identify the errors in the following code and correct them to produce the output shown in
the given sample. You must include comments in your code submission to indicate the
error line that was corrected.
#include<iostream>
using namespace std;
class Singer
{
string pitch, loudness, timbre;
public:
Singer()
{
155.; loudness = 60.;
pitch
timbre = "Tenor";
}
Singer (float p)
{
pitch
= p; loudness = 1; timbre = t;
}
void setVocal(float p, float 1, string t)
{
pitch
= p; loudness =
1; timbre = t;
}
float getPitch()
{
float getloud()
{
string getTimbre()
{
void display()
{
return pitch; }
return loudness; }
return timbre; }
cout<<"\n--
cout<<"Singer Stats\n";
- \n";
-------- \n";
cout<<"Pitch\t: "<<loudness<<" Hz"<<endl;
cout<<"Loudness: "<<pitch<<" dB"<<endl;
cout<<"Timbre\t: "<<timbre<endl;
cout<<"-
}
friend void evalTimbre(Singer&);
};
Transcribed Image Text:(a) Identify the errors in the following code and correct them to produce the output shown in the given sample. You must include comments in your code submission to indicate the error line that was corrected. #include<iostream> using namespace std; class Singer { string pitch, loudness, timbre; public: Singer() { 155.; loudness = 60.; pitch timbre = "Tenor"; } Singer (float p) { pitch = p; loudness = 1; timbre = t; } void setVocal(float p, float 1, string t) { pitch = p; loudness = 1; timbre = t; } float getPitch() { float getloud() { string getTimbre() { void display() { return pitch; } return loudness; } return timbre; } cout<<"\n-- cout<<"Singer Stats\n"; - \n"; -------- \n"; cout<<"Pitch\t: "<<loudness<<" Hz"<<endl; cout<<"Loudness: "<<pitch<<" dB"<<endl; cout<<"Timbre\t: "<<timbre<endl; cout<<"- } friend void evalTimbre(Singer&); };
friend void evalTimbre(Singer &s)
{
if(s.pitch>260)
s.timbre = "Soprano";
else if(s.pitch>=220&&s.pitch<260)
s.timbre = "Mezzo-Soprano";
else if(s.pitch>=174&&s.pitch<220)
s.timbre = "Alto";
else if(s.pitch>=135&&s.pitch<174)
s.timbre = "Tenor";
else if(s.pitch>=100&&s.pitch<135)
s.timbre = "Baritone";
else
s.timbre = "Bass";
}
int main()
{
Singer s1, s2(198.,80., "Bass");
s1. setVocal (147.,45., "Tenor");
evalTimbre();
evalTimbre();
s1.display();
s2. display();
}
SAMPLE OUTPUT:
Singer Stats
Pitch
: 147 Hz
Loudness: 45 dB
Timbre : Tenor
Singer Stats
: 198 Hz
Pitch
Loudness: 80 dB
Timbre : Alto
Transcribed Image Text:friend void evalTimbre(Singer &s) { if(s.pitch>260) s.timbre = "Soprano"; else if(s.pitch>=220&&s.pitch<260) s.timbre = "Mezzo-Soprano"; else if(s.pitch>=174&&s.pitch<220) s.timbre = "Alto"; else if(s.pitch>=135&&s.pitch<174) s.timbre = "Tenor"; else if(s.pitch>=100&&s.pitch<135) s.timbre = "Baritone"; else s.timbre = "Bass"; } int main() { Singer s1, s2(198.,80., "Bass"); s1. setVocal (147.,45., "Tenor"); evalTimbre(); evalTimbre(); s1.display(); s2. display(); } SAMPLE OUTPUT: Singer Stats Pitch : 147 Hz Loudness: 45 dB Timbre : Tenor Singer Stats : 198 Hz Pitch Loudness: 80 dB Timbre : Alto
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Print statement
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,