Question

Write an application that displays a series of at least five student ID numbers (that you...

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 or greater than 0). Catch the ScoreException and then prompt the user to re-enter the score. At the end of the application, display all the student IDs and scores. Save the file as ScoreException.java and TestScore.java.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import iava.util.Scanner public class ScoreException public static void main(Stringl args) throws InValid_Num intl Stud_ID 10for (inti -0; i <5; i++) Svstem.out.printin( Score of the Studentld Stud_IDi] is + Stud _Score[i //If invalid number enterF:Nsoftwares java jdk1.6 \bin>javac ScoreException.java F:\software s〈javaydk1.6くbin〉java Enter the score of the Student Id 3ministr Windowslsystem32vcmd exe F:Nsoftwares java jdk1.6Nbin javac ScoreException.java F:Nsoftwares java jdk1.6\bin java Sco

Code:

import java.util.Scanner;
public class ScoreException
{
public static void main(String[] args) throws InValid_Num
{
  int[] Stud_ID = { 01, 02, 03, 04, 05 };
  double[] Stud_Score = new double[5];
  try
  {
   for (int i = 0; i < 5; i++)
   {
    //enter 5 student marks
    System.out.println("Enter the score of the Student Id " + Stud_ID[i]);
    Scanner Scan = new Scanner(System.in);
    Stud_Score[i] = Scan.nextDouble();
    
    //checking for the condition
    if (Stud_Score[i] < 0 || Stud_Score[i] > 100 )
    {
     throw new InValid_Num("Please Enter a Valid Number ");
    }
   }
   
   //Display the output
   for (int i = 0; i < 5; i++)
   {
    System.out.println("Score of the StudentId " + Stud_ID[i] + " is " + Stud_Score[i]);
   }
  }
  
  //If invalid number entered catches the exception
  catch (InValid_Num in)
  {
   in.printStackTrace();
  }
}
}

Add a comment
Know the answer?
Add Answer to:
Write an application that displays a series of at least five student ID numbers (that you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write an application that displays a series of at least five student ID numbers (that you...

    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...

  • (I would like this to be in five parts.) Write a program (Python module) that includes...

    (I would like this to be in five parts.) Write a program (Python module) that includes a function named studentrecords. This function must support execution of two loops. The first loop is to query the user whether they wish to enter additional records or not. It must accept responses of either yes or no as input, regardless of the letter-cases used for individual letters in the response. If the response is not recognized ( it isn’t yes or no) it...

  • CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes...

    CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

  • Write a program named ClassifyScores that classifies a series of scores entered by the user into...

    Write a program named ClassifyScores that classifies a series of scores entered by the user into ranges (0-9, 10-19, and so forth). The scores will be numbers between 0 and 100. Design and implement a program to prompt the user to enter each score separately. If the score is within the correct range, then increment the appropriate range If the score entered is greater than 100, display an error message, ignore the incorrect score, and prompt for the user to...

  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

  • Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a...

    Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...

  • Create a class named Student, where each Student consists of a student id (a number between...

    Create a class named Student, where each Student consists of a student id (a number between 0 and 99999), grade level (1-12), and a full name. Include set and get methods for all fields. Save this as Student.java. Then, write an application that declares a Student object and prompts the user for the three required pieces of information, one at a time. For student id, keep prompting until the user enters a valid number (0-99999). Likewise, keep prompting for a...

  • in C++ You are to define a structure containing the id number, three test scores, and...

    in C++ You are to define a structure containing the id number, three test scores, and their average, for each student in a class of 20. The file pr2data.txt is included and contains the data. The program is to include the following: A function that reads 20 records of data from the file, finds the average for each student and prints each student’s record. A function that lists the ids and averages for all the students whose average is above...

  • Hello. can anyone solve this. i am having hard time with this. please post a solution...

    Hello. can anyone solve this. i am having hard time with this. please post a solution ASAP a) Create a class named Student. Data fields for Student class include an integer Student ID, a String name, and a double CGPA. Methods include a constructor that requires values for all data fields, as well as get and set methods for each of the data fields. b) Create an application that allows a user to enter values for an array of 15...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT