Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main(){
  4.    
  5.     int input = 0;
  6.     int gradeCount = 0;
  7.     int gradeSum = 0;
  8.    
  9.     while (input >= 0) {
  10.        
  11.         std::cout << "Enter grade (-1 finish)\n";
  12.         std::cin >> input;
  13.         if (input > 0) {
  14.             gradeCount++;
  15.             gradeSum+=input;
  16.             std::cout << "Grade " << input << "% added\n";
  17.         }  
  18.     }
  19.    
  20.     std::cout << "Average GPA is " << gradeSum / gradeCount;
  21.      
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement