Question

In: Computer Science

Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import...

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);
  }
}

Solutions

Expert Solution

Answer.

Step 1

Objective: We need to draw a flowchart and depict pseudocode for the given Java program. A flowchart, algorithm, or pseudocode should always be free from the syntax of any particular programming language. Hence, the overall processes are shown here.

Step 2

Pseudocode:

Start

Step 1: Create an integer array, arr to store student id of capacity 5.

Step 2: Assign id for each student as,
arr[0] := 20025
arr[1] := 20026
arr[2] := 20027
arr[3] := 20031
arr[4] := 20024

Step 3: Creating an array, stuScore to store score for each student

Step 4: for i := 0 to arr.length, i++

loop

Print a message to the user

Enter into the try block

Read a score and store in stuScore[i].

If stuScore[i] is less than or equal to 0 then,
throw ScoreException printing an error message

Assign stuScore[i] := 0
End if

End try block

End loop

Step 5: For int i := 0 to i arr.length, i++

loop

Print stu id and score

End loop

Step 6: End

Step 3

Flowchart:

Thank you.


Related Solutions

Please I can get a flowchart and a pseudocode for this java code. Thank you //import...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new...
Please can I kindly get a flowchart for this java code. Thank you. //import the required...
Please can I kindly get a flowchart for this java code. Thank you. //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in));...
Question: Can I get the code in Java for this assignment to compare? Please and thank you....
Question: Can I get the code in Java for this assignment to compare? Please and thank you. Can I get the code in Java for this assignment to compare? Please and thank you. Description Write a Java program to read data from a text file (file name given on command line), process the text file by performing the following: Print the total number of words in the file. Print the total number of unique words (case sensitive) in the file. Print...
I needv pseudocode and a flowchart for the following java code public class AcmePay { public...
I needv pseudocode and a flowchart for the following java code public class AcmePay { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int hours, shift, retirement = 0; do { System.out.print("Enter the number of hours worked (>0): "); hours = scanner.nextInt(); } while (hours <= 0); do { System.out.print("Enter shift [1 2 or 3]: "); shift = scanner.nextInt(); } while (shift < 1 || shift > 3); if (shift == 2 || shift ==...
Can you please rewrite this Java code so it can be better understood. import java.util.HashMap; import...
Can you please rewrite this Java code so it can be better understood. import java.util.HashMap; import java.util.Scanner; import java.util.Map.Entry; public class Shopping_cart {       static Scanner s= new Scanner (System.in);    //   declare hashmap in which key is dates as per mentioned and Values class as value which consists all the record of cases    static HashMap<String,Item> map= new HashMap<>();    public static void main(String[] args) {        // TODO Auto-generated method stub        getupdates();    }...
Please enter flowchart. Thank you! from tkinter import * from tkinter.scrolledtext import ScrolledText #method to open...
Please enter flowchart. Thank you! from tkinter import * from tkinter.scrolledtext import ScrolledText #method to open file and load contents into text field def open_file(): #fetching file name from filenamevar StringVar filename=filenamevar.get() try: #opening file in read mode file=open(filename,'r') #reading text text=file.read() #replacing current text in textField to read text textField.replace("1.0",END,text) #closing file file.close() except: #displaying error message in textField textField.replace("1.0", END, 'File not found!') #method to save current contents of file into file mentioned in file name entry field...
How would I prepare pseudocode and a flowchart for this? import java.util.Scanner; public class HotDogsBuns {...
How would I prepare pseudocode and a flowchart for this? import java.util.Scanner; public class HotDogsBuns {    private static int HOTDOG_COUNT_PKG = 10;    private static int BUNS_COUNT_PKG = 8;       public static void main(String[] args) {        //Scanner object to get user input        Scanner keyboard = new Scanner(System.in);               // Get number of people        System.out.print("How many people will be competing in the contest?: ");        int noOfPeople = keyboard.nextInt();...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog {...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog { String catalog_name; ArrayList<Item> list; Catalog(String cs_Gift_Catalog) { list=new ArrayList<>(); catalog_name=cs_Gift_Catalog; } String getName() { int size() { return list.size(); } Item get(int i) { return list.get(i); } void add(Item item) { list.add(item); } } Thanks!
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class...
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class Phase1 { /* Translates the MAL instruction to 1-3 TAL instructions * and returns the TAL instructions in a list * * mals: input program as a list of Instruction objects * * returns a list of TAL instructions (should be same size or longer than input list) */ public static List<Instruction> temp = new LinkedList<>(); public static List<Instruction> mal_to_tal(List<Instruction> mals) { for (int...
I need the Java Code and Flowchart for the following program: Suppose you are given a...
I need the Java Code and Flowchart for the following program: Suppose you are given a 6-by-6 matrix filled with 0s and 1s. All rows and all columns have an even number of 1s. Let the user flip one cell (i.e., flip from 1 to 0 or from 0 to 1) and write a program to find which cell was flipped. Your program should prompt the user to enter a 6-by-6 array with 0s and 1s and find the first...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT