Exception Project JAVA Create a Java program that searches for a student’s ID or name in a text file, complete the findID() and findName() functions. Then, insert a try/catch statement in main() to catch any exceptions thrown by findID() or findName(), and output the exception message. Each line in the text file contains a name and ID separated by a space. Function findID() has two parameters: a student's name (string) and the text file's contents (infile, input file variable). The function findID() returns the ID associated with the student's name if the name is in the file, otherwise the function throws a runtime error with the message "Student ID not found for studentName", where studentName is the name of the student. Function findName() has two parameters: a student's ID (string) and the text file's contents (infile). The function findName() returns the name associated with the student's ID if the ID is in the file, otherwise the function throws a runtime error with the message "Student name not found for studentID", where studentID is the ID of the student. The main program takes three inputs from a user: the name of a text file (string), the search option for finding the ID or name of a student, and the ID or name of a student (string). If the search option is false, findID() is invoked with the student's name as an argument. If the search option is true, findName() is invoked with the student's ID as an argument. The main program outputs the search result or the caught exception message. Ex: If the input of the program is: roster.txt 0 Reagan and the contents of roster.txt are: Reagan rebradshaw835 Ryley rbarber894 Peyton pstott885 Tyrese tmayo 945 Caius ccharlton329 the output of the program is: rebradshaw835 Ex: If the input of the program is: roster.txt 0 Mcauley the program outputs an exception message: Student ID not found for Mcauley Ex: If the input of the program is: roster.txt 1 rebradshaw835 the output of the program is: Reagan Ex: If the input of the program is: roster.txt 1 mpreston272 the program outputs an exception message: Student name not found for mpreston272 NOTE: Please feel free to make content of your file the way you like. You may use an ArrayList to hold the content of the file. You may change the parameters of your findID or finadName. Hint. Try first to have a file, read the content and print to see it works first.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Exception Project JAVA

Create a Java program that searches for a student’s ID or name in a text file, complete the findID() and findName() functions. Then, insert a try/catch statement in main() to catch any exceptions thrown by findID() or findName(), and output the exception message. Each line in the text file contains a name and ID separated by a space.

Function findID() has two parameters: a student's name (string) and the text file's contents (infile, input file variable). The function findID() returns the ID associated with the student's name if the name is in the file, otherwise the function throws a runtime error with the message "Student ID not found for studentName", where studentName is the name of the student.

Function findName() has two parameters: a student's ID (string) and the text file's contents (infile). The function findName() returns the name associated with the student's ID if the ID is in the file, otherwise the function throws a runtime error with the message "Student name not found for studentID", where studentID is the ID of the student.

The main program takes three inputs from a user: the name of a text file (string), the search option for finding the ID or name of a student, and the ID or name of a student (string). If the search option is false, findID() is invoked with the student's name as an argument. If the search option is true, findName() is invoked with the student's ID as an argument. The main program outputs the search result or the caught exception message.

Ex: If the input of the program is:

roster.txt 0 Reagan

and the contents of roster.txt are:

Reagan rebradshaw835

Ryley rbarber894

Peyton pstott885

Tyrese tmayo 945

Caius ccharlton329

the output of the program is:

rebradshaw835

Ex: If the input of the program is:

roster.txt 0 Mcauley

the program outputs an exception message:

Student ID not found for Mcauley

Ex: If the input of the program is:

roster.txt 1 rebradshaw835

the output of the program is:

Reagan

Ex: If the input of the program is:

roster.txt 1 mpreston272

the program outputs an exception message:

Student name not found for mpreston272

NOTE: Please feel free to make content of your file the way you like.

You may use an ArrayList to hold the content of the file. You may change the parameters of your findID or finadName.

Hint. Try first to have a file, read the content and print to see it works first.



Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Exception Handling Keywords
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education