Advertisement
Spocoman

Online Education

Sep 23rd, 2023 (edited)
1,244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int onlineStudents = 0, onsiteStudents = 0, studentCount;
  8.  
  9.     string educationForm;
  10.  
  11.     for (int i = 0; i < 3; i++) {
  12.         cin >> educationForm;
  13.         cin >> studentCount;
  14.  
  15.         if (educationForm == "online") {
  16.             onlineStudents += studentCount;
  17.         }
  18.         else {
  19.             onsiteStudents += studentCount;
  20.         }
  21.     }
  22.  
  23.     if (onsiteStudents > 600) {
  24.         onlineStudents += onsiteStudents - 600;
  25.         onsiteStudents = 600;
  26.     }
  27.  
  28.     cout << "Online students: " << onlineStudents << endl
  29.         << "Onsite students: " << onsiteStudents << endl
  30.         << "Total students: " << onlineStudents + onsiteStudents << endl;
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement