Completely lost

Okay folks, I'm completely lost, I'm new to C++ and have no idea how to start. I'm aware that there's "no doing peoples homework" rule in affect, but I'm several chapters behind and am trying to catch up. With that said, can someone please at least get me started or show me an example similar to this problem. The help is greatly appreciated and I'll buy you a donut if you can help:

Write a program that prompts the user to input seven values – each value represents the number of inches of rainfall on a particular day of the week. (Note: The values may be whole units such as 2 or 5 or fractional values such as 2.5 or 1.33. Make sure you chose an appropriate data type to handle either type of data.) Based on the input, calculate the total rainfall and average rainfall for the seven days period. Output the total and average in decimal form.

Please, I am begging, please help. Thanks in advance.
Last edited on
Do you know how to output words to the screen? Do you know how to fetch input from the keyboard?
you mean cin>> and cout<<, yes, i'm familiar with that. I just have a hard time putting it all together
Small steps. Just do this to begin with; write a program that prompts the user to input seven values
using namespace std;


int main()
{
int inches;


cout << "enter seven values";
cin>>inches;

return 0;
}

how's that look?
OP wrote:
cin>>inches;

All the seven values just going into one variable?

Making seven variables or an array of double or float(and not int because:
Note: The values may be whole units such as 2 or 5 or fractional values such as 2.5 or 1.33. Make sure you chose an appropriate data type to handle either type of data.)
).

Do you want a sample code--and oh with explanation? Answer FAST or else, ZZzzzz,
Aceix.
Last edited on
yes
I think I got something, I compiled it and got my message.


#include <iostream>

using namespace std;


int main()
{
double num;


cout << "enter seven numbers";
cin>>num;
cout <<"Thank you"<<endl;

return 0;
}
Ok,
But first, do you know about arrays and loops?
If yes:

1
2
3
4
5
6
7
8
9
10
11
main()
{
     float inch[7];   //declare an array of int called inch, with 7 elements(ie: 0-6 will be the index for the elements.

     cout<<"Enter seven values: ";  //Hope you know this
     for(int i=0;i<6;i++)  //a for loop that runs as long as i<6, and i increases everytime the loop runs completely.
     {
          cin>>inch[i]; //fills every element of the array, with user input. This works based on the value of i.
     }
}
//Hope you can do the rest! 


Else if no:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
main()
{
     float inch1;
     float inch2;
     float inch3;
     float inch4;
     float inch5;
     float inch6;
     float inch7;

     cout<<"Enter seven values: ";
     cin>>inch1>>inch2>>inch3>>inch4>>inch5>>inch6>>inch7;   //This "fills" or assigns each variable with a value based on user input. Note that any space or newline character will cause the value after the whitespace character to be given to the next variable.
}

//Good luck 


Hope it helps,
Aceix.
thanks, there's a donut coming your way
Last edited on
Topic archived. No new replies allowed.