Heyy guys,
my code is below..i don't know what is happening but when i enter the first month in the output window enter month#2 and enter month#3 gets skipped and also the Now enter the amount of rain (in inches) for each month" and then there are two letters of month are displayed and then i type something and it closes down..i am new at C++.
Thanks
#include <iostream>
#include <string>
using namespace std;
userInput4, 5 and 6 should be doubles, not chars. I suggest choosing better names for your variables. And, generally, when you have something like variable1, variable2 ... variableN, you should be using a container, but you might not have learned how yet.
Also, I know why they skip. userInput1, 2 and 3 are chars. They only accept one character. So if I input August, it will store A in userInput1, u in userInput 2 and so forth.
I suggest you use strings.
it works fine upto when i enter the first value for amount of rain for my first month which is june but then it just says july, august and some other crap..thanks if u can try some more
Well you declared userInput as char. So when you're inputting do you enter single character like, 'A' or 'B'? If not you're going to have problems. If you don't want to use the code I posted above and you want to use yours do it like this :
just send me the code..the purpose is to get the average rain in inches when the user enters all the things for ex june as a month and 5.4 inches as rain in that month and then at the end the average of 3 months rain in inches.
Enter month #1:
June
Enter month #2:
March
Enter month #3:
April
Now enter the amount of rain (in inches) for each month
June
5.4
March
30
April
21
The average monthly rainfall for June, March and April was 18.8 inches
char is for storing a single character. An example would be "A".
int is for storing an integer. An example would be "1234".
float is for storing a floating point number. An example would be "2.5".
double is for large floating point numbers.