Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import java.util.Scanner; ;//import Scanner to take input from user public class TestScore { @SuppressWarnings("resource") public static void main(String[] args) throws ScoreException {//main method may throw Score exception int [] arr = new int [5]; //creating an integer array for student id arr[0] = 20025; //assigning id for each student arr[1] = 20026; arr[2] = 20027; arr[3] = 20031; arr[4] = 20024; int [] stuScore = new int[arr.length]; //Creating an array of stuScore to store each stu score Scanner sc = new Scanner (System.in); //Initializing Scanner input for (int i = 0; i < arr.length; i++) {//iterating through each student System.out.print("enter score for stu id " + arr[i] + ":");//prompting user to enter score try { stuScore[i] = sc.nextInt();//taking user input if (stuScore[i] <= 0) {//if student score is less than or equal to 0 //throwing Score exception throw new ScoreException( "Score cannot be negative, so we are assigning 0 by default to your score"); } } catch (ScoreException e) { System.out.println(e.getMessage());//print only the message stuScore[i] = 0; //assign the value to 0 } } for (int i = 0; i < arr.length; i++) { System.out.println("stu id =" + arr[i] + " score for stu:" + stuScore[i]); //printing stu id and their corresponding score } } } ScoreException.java public class ScoreException extends Exception { ScoreException (String s) { super(s); } }
Please can I get a flowchart and pseudocode for this java code. Thank you.
TestScore.java
import java.util.Scanner; ;//import Scanner to take input from user
public class TestScore {
@SuppressWarnings("resource")
public static void main(String[] args) throws ScoreException {//main method may throw Score exception
int [] arr = new int [5]; //creating an integer array for student id
arr[0] = 20025; //assigning id for each student
arr[1] = 20026;
arr[2] = 20027;
arr[3] = 20031;
arr[4] = 20024;
int [] stuScore = new int[arr.length]; //Creating an array of stuScore to store each stu score
Scanner sc = new Scanner (System.in); //Initializing Scanner input
for (int i = 0; i < arr.length; i++) {//iterating through each student
System.out.print("enter score for stu id " + arr[i] + ":");//prompting user to enter score
try {
stuScore[i] = sc.nextInt();//taking user input
if (stuScore[i] <= 0) {//if student score is less than or equal to 0
//throwing Score exception
throw new ScoreException(
"Score cannot be negative, so we are assigning 0 by default to your score");
}
}
catch (ScoreException e) {
System.out.println(e.getMessage());//print only the message
stuScore[i] = 0; //assign the value to 0
}
}
for (int i = 0; i < arr.length; i++) {
System.out.println("stu id =" + arr[i] + " score for stu:" + stuScore[i]); //printing stu id and their corresponding score
}
}
}
ScoreException.java
public class ScoreException extends Exception {
ScoreException (String s) {
super(s);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images