Average Rainfall 09-11-2014, 12:56 AM
#1
hey guys so for my c++ class we have these programming assignments assigned. My output keeps just being one line with no spaces. any reason why it's doing this?
Final output looks like this:
Enter month:Enter rainfall for:May Enter month: Enter rainfall for:June Enter month:Enter rainfall for:July The average rainfall for May,June, and July is 8.1 inches
^^ why is it so clustered? I'm using a online website my teacher assigned could it be that site?
Final output looks like this:
Enter month:Enter rainfall for:May Enter month: Enter rainfall for:June Enter month:Enter rainfall for:July The average rainfall for May,June, and July is 8.1 inches
^^ why is it so clustered? I'm using a online website my teacher assigned could it be that site?
Code:
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main(){
string month1,month2,month3;
double rainfall1,rainfall2,rainfall3;
cout<<"Enter month:";
cin>>month1;
cout<<"Enter rainfall for:"<<month1<<endl;
cin>>rainfall1;
cout<<"Enter month:"<<endl;
cin>>month2;
cout<<"Enter rainfall for:"<<month2<<endl;
cin>>rainfall2;
cout<<"\n"<<"Enter month:";
cin>>month3;
cout<<"Enter rainfall for:"<<month3<<endl;
cin>>rainfall3;
double average = (rainfall1 + rainfall2 + rainfall3)/3;
cout<<setprecision(2)<<"The average rainfall for " <<month1 <<","<<month2<<", and "<<month3<<" is " << average<<" inches"<<endl;
return 0;
}

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)