90 168
Assignments Done
99.5%
Successfully Done
In September 2020

# Answer to Question #6522 in C++ for Dan Togaila

Question #6522
I&#039;m horrible at typing code and i&#039;m having trouble with this for my C++ class

3.4: Average Rainfall
Write a program that calculates the average rainfall for three months. The program should ask the user to enter the name of each month, such as June or July, and the amount of rain (in inches) that fell each month. The program should display a message similar to the following:

The average rainfall for June, July, and August is 6.72 inches.

Prompts And Output Labels: Each month read should be prompted for by the string &quot;Enter month: &quot; and each rainfall amount should be prompted for by a string of the form &quot;Enter rainfall for MONTH: &quot; where MONTH is the name of the month that was just entered. The output should be of the form: &quot;The average rainfall for MONTH1, MONTH2, and MONTH3 is: AVERAGE&quot; where MONTH1, MONTH2, and MONTH3 are the month names that were entered by the user and where AVERAGE is the calculated average rainfall shown with exactly two digits past the decimal point.
1
2012-02-16T07:23:19-0500
#include<iostream.h>
#include<conio.h>

class rain
{
float inch1,inch2,inch3;
char m1[10],m2[10],m3[10];
public: void getdata();
void putdata();
};

inline void rain::getdata()
{
cout<<"enter the name of the 3 months\n";
cin>>m1>>m2>>m3;
cout<<"enter the rainfall in inches for the 3 months\n";
cin>>inch1>>inch2>>inch3;
}

inline void rain::putdata()
{
float avg=(inch1+inch2+inch3)/3;
cout<<"the average rainfall for";
cout<<m1<<","<<m2<<"',"<<m3<<" is "<<(inch1+inch2+inch3)/3<<"\n";
}

void main()
{
rain r;
r.getdata();
r.putdata();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!