EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

Question
Book Icon
Chapter 12, Problem 8PE
Program Plan Intro

Display IDs with scores

Program plan:

Filename: “ScoreException.java”

  • Define “ScoreException” class which extends from “Exception” class
    • Define the constructor
      • Call the super method.

Filename: “TestScore.java”

  • Include the header file
  • Define the class “TestScore”
    • Define the “main” method
      • Declare the variables and set the required values to the variables
      • Iterate “for” loop until it reaches length of the “ids”
        • Get the scores from the user
        • In “try” block,
          • Check “scores[x]” is greater than “HIGHLIMIT”
            • Set the score
            • Throw an exception
        • In “catch” block, display the error and set “scores[x]” is 0
      • Display the five ids with scores

Blurred answer
Students have asked these similar questions
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 and then display an appropriate message. In addition, store a 0 for the student’s score. At the end of the application, display all the student IDs and scores. Save the files as ScoreException.java and TestScore.java.
Make 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. Make 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.   public class ScoreException extends Exception {    public ScoreException(String s) {    } }     import java.util.*; public class TestScore {    public static void main(String args[]) throws Exception {        Scanner input = new Scanner(System.in);        int[] ids = {1234, 2345, 3456, 4567, 5678};        int[] scores = {0, 0, 0, 0, 0};        String scoreString = new String();        final int HIGHLIMIT = 100;        String inString, outString = "";        for (int x = 0; x < ids.length; ++x)…
Write an application containing three parallel arrays that hold 10 elements each.  The first array hold four-digit student ID numbers, the second array holds first names, and the third array holds the students’ grade point averages.  Use dialog boxes to accept a student ID number and display the student’s first name and grade point average.  If a match is not found, display an error message that includes the invalid ID number and allow the user to search for a new ID number. java program
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage