Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int onlineStudents = 0,
- onsiteStudents = 0,
- studentCount;
- String educationForm;
- for (int i = 0; i < 3; i++) {
- educationForm = scanner.nextLine();
- studentCount = Integer.parseInt(scanner.nextLine());
- if (educationForm.equals("online")) {
- onlineStudents += studentCount;
- } else {
- onsiteStudents += studentCount;
- }
- }
- if (onsiteStudents > 600) {
- onlineStudents += onsiteStudents - 600;
- onsiteStudents = 600;
- }
- System.out.println(
- "Online students: " + onlineStudents +
- "\nOnsite students: " + onsiteStudents +
- "\nTotal students: " + (onlineStudents + onsiteStudents)
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement