boolean markCheck = true; do{ try{ for (int i = 0; i <= amountAssignment-1; i++ ) { System.out.print("Homework Mark for Assignment " +(i+1) + ": "); homeworkMark[i] = Integer.parseInt(sc.nextLine()); System.out.print("Examination Mark for Assignment " + (i+1) + ": "); examinationMark[i] = Integer.parseInt(sc.nextLine()); markCheck = false; } }catch (Exception e) { System.out.println("------------"); System.out.println(" ERROR "); System.out.println("------------"); } }while (markCheck == true);
After asking the mark for assignment 1 it goes directly to my exception without allowing to user to enter anything. After that it works fine!
Cannot understand why
-------------OUTPUT------------
Student Number: 567
Family name: Malcolm
First Name: tanti
Subjects: 1. Boat Maintenance
2. Basic Sail Control
3. Blue Water Navigation
4. Chart Reading
5. Laws and Customs of the sea
Subject: 3
How many assignments shall I calculate? : 2
Homework Mark for Assignment 1: ------------
ERROR
------------
Homework Mark for Assignment 1: f
------------
ERROR
------------
Homework Mark for Assignment 1: 23
Examination Mark for Assignment 1: 45
Homework Mark for Assignment 2: 65
Examination Mark for Assignment 2: 34