Advertisement
Spocoman

Online Education

Sep 8th, 2024 (edited)
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int onlineStudents = 0,
  7.                 onsiteStudents = 0,
  8.                 studentCount;
  9.         String educationForm;
  10.  
  11.         for (int i = 0; i < 3; i++) {
  12.             educationForm = scanner.nextLine();
  13.             studentCount = Integer.parseInt(scanner.nextLine());
  14.  
  15.             if (educationForm.equals("online")) {
  16.                 onlineStudents += studentCount;
  17.             } else {
  18.                 onsiteStudents += studentCount;
  19.             }
  20.         }
  21.  
  22.         if (onsiteStudents > 600) {
  23.             onlineStudents += onsiteStudents - 600;
  24.             onsiteStudents = 600;
  25.         }
  26.  
  27.         System.out.println(
  28.                 "Online students: " + onlineStudents +
  29.                 "\nOnsite students: " + onsiteStudents +
  30.                 "\nTotal students: " + (onlineStudents + onsiteStudents)
  31.         );
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement