1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ELEN [110]
3 years ago
5

Write an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the

user to enter a numeric test score for the student. Create a ScoreException class, and throw a ScoreException for the class if the user does not enter a valid score (less than or equal to 100). Catch the ScoreException, display the message Score over 100, and then store a 0 for the student’s score. At the end of the application, display all the student IDs and scores. g
Computers and Technology
1 answer:
babymother [125]3 years ago
8 0

Answer:

See explaination for the program code

Explanation:

// ScoreException.java

class ScoreException extends Exception

{

ScoreException(String msg)

{

super(msg);

}

}

// TestScore.java

import java.util.Scanner;

public class TestScore

{

public static void main(String args[]) throws ScoreException

{

Scanner sc = new Scanner(System.in);

int studentId[] = { 1201, 1202, 1203, 1204, 1205 };

int scores[] = new int[5];

int score = 0;

for(int i = 0; i < studentId.length; i++)

{

try

{

System.out.print("Enter a numeric test score for the student"+(i+1)+" of Id "+studentId[i]+" : ");

score = sc.nextInt();

if(score < 0 || score > 100)

{

scores[i] = 0;

throw new ScoreException("Input should be between 1 and 100");

}

else

{

scores[i] = score;

}

}

catch(ScoreException ex)

{

System.out.println("\n"+ex.getMessage()+"\n");

}

}

//displaying student details

System.out.println("\n\nStudent Id \t Score ");

System.out.println("=============================");

for(int i = 0; i < studentId.length; i++)

{

System.out.println(studentId[i]+"\t\t"+scores[i]);

}

}

}

You might be interested in
consider the following code segment, which appears in a method in a class other than password. the code segment does not compile
Romashka [77]

The code segment does not compile because the method 'reset' does not return a value that can be displayed.

A method refers to a block of that which only runs when it is called. It is permissible to pass data, referred to as parameters, into a method. Methods are used to accomplish certain actions, and they are also called functions. As per the given code segment that appears as a method in a class, it does not compile because the method named 'reset' is not returning a value that can be printed on the screen as an output.

"

<em>Complete question:</em>

Consider the following code segment, which appears in a method in a class other than password.

Password p = new Password("password");

System.out.println("The new password is " + p.reset("password"));

The code segment does not compile because _____________ .

"

You can learn more about Method at

brainly.com/question/27415982

#SPJ4

4 0
9 months ago
Which of these practices should you follow while creating your resume?
avanturin [10]

B is better than any other one's I think.

8 0
3 years ago
Read 2 more answers
Which of these inventions was necessary to permit magnetic recording?
eimsori [14]
It’s C vinyl records permit magnetic fields
4 0
3 years ago
Read 2 more answers
A ____ dynamic volume can only be created with three or more dynamic disks. raid 1 raid 5 raid 5i raid 23
aev [14]
The answer is Raid 5 and 23
8 0
3 years ago
If you increase the distance between two magnets, what will happen?
zheka24 [161]
The Magnetic attraction will decrease
6 0
3 years ago
Read 2 more answers
Other questions:
  • Amy has decided to use a dark background and light colored text for her prensentation. Which toolbar option will let her change
    5·1 answer
  • Mica's creating his web page with a software that is free of charge for the first month. If he likes the program, he will have t
    8·2 answers
  • What is the software that manages and controls the activities and resources of the computer? O The CPU The OS The ALU The GUI D
    13·1 answer
  • A ____ is a battery-operated power source directly attached to one or more devices and to a power supply (such as a wall outlet)
    14·1 answer
  • Create a Python program that: Allows the user to enter a person's first name and last name. The user should be able to enter as
    12·1 answer
  • Select the correct answer.
    12·2 answers
  • Risk of new technology is NOT evaluated by asking questions during which phase?
    15·1 answer
  • Help please i will mark brainlist!
    7·1 answer
  • Which statement is true regarding Artificial Intelligence (AI)?
    13·1 answer
  • Which statement is true about the energy of electromagnetic radiation?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!