C++ nested loops and while or if

So I run the program and it doesn't run the while loop. the program is supposed to find the number of points to add to each students grade in order for the class average to be at least 70%.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  //         coded by ===Cchadwicka===     9/27/2017 2:35pm
#include "stdafx.h"
#include <iostream>
using namespace std;


int main()
{
	int numStudents = 0;
	int numPointsPossible = 0;
	int numPointsActuallyEarned = 0;

	

	cout << "How many students are in the class?" << endl;                               
	cin >> numStudents;

	cout << " Please enter the number of points possible for the assignment." << endl;     
	cin >> numPointsPossible;

	cout << "Please enter the number of points earned, per student, on the assignment.  Press enter after each entry." << endl;   
	cin >> numPointsActuallyEarned;

	int totalPossiblePoints = 0;
	int numPointsActuallyEarnedTotal = 0;


	int totalPossiblePoints = numPointsPossible * numStudents;
	int numPointsActuallyEarnedTotal = numPointsActuallyEarned * numStudents;
	
	 while 	(numPointsActuallyEarnedTotal / totalPossiblePoints) >= 0.7)   
	    cout << "There is no need to add points to the students grades because the class average is equel to or greater than 70%.  Thankyou for using The Curve Mint.";
	 cout << endl;
	 if (numPointsActuallyEarnedTotal / totalPossiblePoints) < 0.7  
			numPointsActuallyEarnedTotal++
            cout << "You need to add " << (numPointsActuallyEarnedTotal - (numStudents * numPointsActuallyEarned)) / 20 << " to each students individual grade";
              cout << endl;
	 
				 }

		
				   }
	system("PAUSE");
	
    return 0;
}
An int divided by an int will give you an int:

numPointsActuallyEarnedTotal / totalPossiblePoints will always be zero, unless numPointsActuallyEarnedTotal equals totalPossiblePoints, in which case is will be one. int divided by int gives an int.

That said, the while loop has something very wrong with it. It looks like your while loop contains only a single line:
cout << "There is no need to add points to the students grades because the class average is equel to or greater than 70%. Thankyou for using The Curve Mint."; and because that line doesn't change anything, if this loop ever starts it will loop forever. How is this loop ever meant to end?
I was referring to these two examples from my textbook:
=============================================================
#include <iostream>
using namespace std;

// Output GCD of user-input numA and numB

int main() {
int numA = 0; // User input
int numB = 0; // User input

cout << "Enter first positive integer: ";
cin >> numA;

cout << "Enter second positive integer: ";
cin >> numB;

while (numA != numB) { // Euclid's algorithm
if (numB > numA) {
numB = numB - numA;
}
else {
numA = numA - numB;
}
}

cout << "GCD is: " << numA << endl;

return 0;
}
===========================================================
and
=========================================================
#include <iostream>
using namespace std;

int main() {
int numAsterisk = 0; // Number of asterisks to print
int i = 0; // Loop counter

numAsterisk = 0;
while (numAsterisk >= 0) {
cout << "Enter an integer (negative to quit): ";
cin >> numAsterisk;

if (numAsterisk >= 0) {
cout << "Depicted graphically:" << endl;
for (i = 1; i <= numAsterisk; ++i) {
cout << "*";
}
cout << endl << endl;
}
}

cout << "Goodbye." << endl;
return 0;
}
===========================================================
also, im not sure how to allow for the entry of (numStudents) grades in cout line three. like how to allow for the entry of 20 grades into one variable adding each entry .
Topic archived. No new replies allowed.