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
Which of the following is NOT a characteristic developed by New Journalism?
krok68 [10]
Flashy page layouts
7 0
3 years ago
Which of the following best describes open source software?
sp2606 [1]
What was the options they gave you?
5 0
3 years ago
Read 2 more answers
What is cyber crime ? easy definition​
Naddika [18.5K]

Answer:

Cyber crime is defined as a crime in which a computer is the object of the crime (hacking, phishing, spamming) or is used as a tool to commit an offense .

Explanation:

4 0
3 years ago
Which of the following attributes of a website indicates a more reliable source for information?
kkurt [141]
The answer would be B. An attribute of a website that will indicate a more reliable source of information is when the site ends in ".edu". It is a top level domain for education. It would mean that this particular site is linked with universities, colleges or other educational sites thus it gives more information that are real and factual.
5 0
3 years ago
Which of the following is the initial statement in the following for loop? (Assume that all variables are properly declared.) in
Sergeeva-Olga [200]

Answer:

The answer to the given question is "i=1".

Explanation:

In the given c++ code the we use the for loop. We use this loop when we know exactly how many times it will execute. This loop is also known as entry control loop.

Syntax :

for(initialization; condition ; increment/decrements)  

{  

C++ statement(s);  

}

Example:

for (int i = 1; i < 20; i++)  

{

cout<< "Hello";

}

That's why initial statement for the for loop is "i=1".

3 0
3 years ago
Other questions:
  • kai is interviewing for a job, and the interviewer asks him for an example of skill at cooperating with others. Which example be
    14·2 answers
  • How do networks help protect data? -by preventing access by more than one person at a time -by restricting access to department
    11·2 answers
  • You can click a web page title on the _____ list to return to that page.
    10·1 answer
  • If you will be giving your presentation to an audience, you can practice your presentation by using View, ___________, to rehear
    14·1 answer
  • Which of the following are characteristics of a cell
    12·1 answer
  • The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IE
    12·1 answer
  • One advantage of using personal computers for Internet access is that they have relatively large screens for viewing Internet co
    7·2 answers
  • If you Buy my group clothing in R.o.b.l.o.x for a donation i will make you brainliest
    14·2 answers
  • What is the benefit of making an archive folder visible in the Outlook folder list?
    6·1 answer
  • If you select one slice of pie in a pie chart, you have selected a ____
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!