User input for student grades is too verbose I need some help with this beginner C++ program (it's an assignment). How can I use a single variable and make the program get the six inputs I need instead of using a variable for each input?

#include &lt;iostream&gt;
using namespace std;

int main()

{

double grade1,grade2,grade3,grade4,grade5,grade6;
double totalGrade;
cout &lt;&lt; "program to calculate grade" &lt;&lt; endl &lt;&lt; endl;
cout &lt;&lt; "hi please enter the six grades ";
     &lt;&lt; endl &lt;&lt; endl;

cin &gt;&gt; grade1;
cin &gt;&gt; grade2;
cin &gt;&gt; grade3;
cin &gt;&gt; grade4;
cin &gt;&gt; grade5;
cin &gt;&gt; grade6;


grade1 = grade1 * 0.125;
grade2 = grade2 * 0.125;
grade3 = grade3 * 0.05;
grade4 = grade4 * 0.05;
grade5 = grade5 * 0.05;
grade6 = grade6 * 0.1;



totalGrade = grade1 + grade2 + grade3 + grade4 + grade5 + grade6;


if((totalGrade &gt;= 9.5) &amp;&amp; (totalGrade &lt;= 10)) {
    cout &lt;&lt; "grade is: &gt;&gt; " &lt;&lt; totalGrade &lt;&lt; endl &lt;&lt; endl;
    cout &lt;&lt; "you have approved + " &lt;&lt; endl;
    }
else if ((totalGrade &gt;= 9) &amp;&amp; (totalGrade &lt;= 9.5)) {
    cout &lt;&lt; "grade is &gt;&gt; " &lt;&lt; totalGrade &lt;&lt; endl &lt;&lt; endl;
    cout &lt;&lt; "you have approved -" &lt;&lt; endl;
    }
else if (totalGrade &lt; 9) {
    cout &lt;&lt; "grade is: &gt;&gt; " &lt;&lt; totalGrade &lt;&lt; endl &lt;&lt; endl;
    cout &lt;&lt; "you have reproved  "&lt;&lt; endl;

    }


return 0;
}
You should move most of the logic out of the main() function and into its own function or functions.  But perhaps you're not there yet in your class.  

Similarly, using namespace std is not recommended.  See here.  Obviously this won't matter in this program, but it's a bad habit that you may want to avoid starting.  

double grade1,grade2,grade3,grade4,grade5,grade6;


Whenever I see something like this, I want to rewrite it as an array:

const int NUMBER_OF_GRADES = 6;
double grades[NUMBER_OF_GRADES];


Personally, I'd also put the grade weights into their own array, but that's up to you.  You could also use a switch statement or an if/else if construct to handle the grade weights.  

If you use a for loop to iterate over the entries of the array and calculate the totalGrade incrementally in each iteration over the loop, I think that you will be able to see how to use a single grade variable to replace the entries of the array.  If your class hasn't done for loops yet, you can get the same effect by ordering all uses of grade[0] or grade1 before you do anything with grade[1] or grade2.  This means that you will have to replace 

totalGrade = grade1 + grade2 + grade3 + grade4 + grade5 + grade6;


with six separate statements that have the same effect.  

As a matter of policy, you should probably do more error checking when you do a cin.  If you look around this site, you should be able to find several examples of people using while loops with error checking.  

When I've seen people put the } and else on separate lines, they've always been in the same column.  Like this:

if (totalGrade &lt; 9) {
    cout &lt;&lt; "grade is: &gt;&gt; " &lt;&lt; totalGrade &lt;&lt; endl &lt;&lt; endl;
    cout &lt;&lt; "you have reproved  "&lt;&lt; endl;
}
else if (totalGrade &lt; 9.5) {
    // the else makes this implicitly greater than or equal to 9
    cout &lt;&lt; "grade is &gt;&gt; " &lt;&lt; totalGrade &lt;&lt; endl &lt;&lt; endl;
    cout &lt;&lt; "you have approved -" &lt;&lt; endl;
}
else if (totalGrade &lt;= 10) {
    // the else makes this implicitly greater than or equal to 9.5
    cout &lt;&lt; "grade is: &gt;&gt; " &lt;&lt; totalGrade &lt;&lt; endl &lt;&lt; endl;
    cout &lt;&lt; "you have approved + " &lt;&lt; endl;
}


I personally put them on the same line.  Putting them on separate lines leads to people separating them, which can lead to confusion.  

Note that I changed the order.  This makes no functional difference, but it reduces the number of comparisons that you need to do.  Also, I'm not sure that you have to check that totalGrade &lt;= 10.  A simple else might be enough for the last one.  

You might want to think about why I changed &lt;= 9.5 to &lt; 9.5.  Hint:  I had to do that to keep the effect the same after I changed the order.  

cout &lt;&lt; "hi please enter the six grades ";
     &lt;&lt; endl &lt;&lt; endl;


This looks horribly wrong.  It may work but it is fragile.  Either remove the ; from the first line or add a cout to the beginning of the second line.