Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please rewrite this code as Pseudo-Code,.. basically rewrite the code but in eng

ID: 3828508 • Letter: P

Question

please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank you so much!

example if (5>= test) should be written as if (5 is greater or equal to test)

class TestScores

{
private int scores[]=new int[5];
public TestScores(int test[])
{
//to validate input test score

try
{
for(int i=0;i<5;i++)
{

if (test[i]<0||test[i]>100) //condition
//Throws an exception when test score is (Score <0 || Score >100)
throw new IllegalArgumentException("Number cannot" +

" be less than 0 and greater than 100");
else

scores[i]=test[i];
}

//function call to print average

System.out.println("Your Average Test Score is:"+Average());
}

catch(IllegalArgumentException e)
{
System.out.println(e);
}
}

//function average

public double Average()
{
//variable initialized to 0
int sum=0;
double avg;
for(int i=0;i<5;i++)
{
sum+=scores[i];
}
avg=sum/5;

return avg;

}//end Average

}//end TestScores class

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

import java.util.Scanner;
class TestScoresDemo
{
public static void main(String args[]) throws Exception

{
Scanner kb = new Scanner(System.in);
int array[]=new int[5];//array declaration
//inputting test scores
System.out.println("Please Enter TestScores");
for(int i=0;i<5;i++)

array[i]=kb.nextInt();//Reading array of TestScores

//Creating instance to class TestScore

TestScores t1=new TestScores(array);

System.exit(0);

}

}

Explanation / Answer

CREATE A CLASS TestScores


DECLARE private int scores[]=new int[5];
CONSTRUCTOR public TestScores(int test[])

TRY

FOR int i=0 to i<5

IF (test[i] is less than zero OR test[i] is greater than 100) //condition
            //Throws an exception when test score is (Score <0 || Score >100)
            throw new IllegalArgumentException("Number cannot" +" be less than 0 and greater than 100");
ELSE

                        DO scores[i]=test[i];
                        END FOR

PRINT ("Your Average Test Score is:"+Average());
END TRY BLOCK

CATCH A EXCEPTION catch(IllegalArgumentException e)
    PRINT e
END CATCH BLOCK

END CONSTRUCTOR

FUNCTION public double Average()

DECLARE and INITIALIZE sum=0;
DECLARE double avg
FOR int i=0 to i<5
     DO sum+=scores[i];
END FOR
DO avg=sum/5

RETURN avg

END AVERAGE()

END CLASS TestScores

IMPORT JAVA PACKAGE import java.util.Scanner;

CREATE MAIN CLASS TestScoresDemo


MAIN FUNCTION public static void main(String args[]) throws Exception

CREATE A OBJECT OF SCANNER CLASS TO INPUT
DECLARE AN ARRAY LIKE int array[]=new int[5]
PRINT "Please Enter TestScores"
FOR int i=0 to i<5

READING ARRAY array[i]=kb.nextInt();

CREATE INSTANCE OF CLASS TestScore

TestScores t1=new TestScores(array);

EXIT

END MAIN FUNCTION

END CLASS TestScoresDemo