Building on Lab Assignment 9 (TestScores Class Custom Exception), modify your code as follows: Read in an array of test scores from a file. If any of the test scores are invalid (via InvaidTestScore exception), then skip the invalid test score and continue to process your input file until an EOF (end-of-file); write out to a new (valid) data file. You may choose your input data file regarding values. For the File I/O, you should use: InputStream and OutputStream Classes. Only the Java code is needed for this assignment. Basic Example: File inputFile = new File("readTestScores.txt"); File outputFile = new File("writeTestScores.txt"); FilelnputStream fis = new FilelnputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile); For Reference (Lab 9 Assignment) 1. TestScores Class Write a class named Testscores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException. Demonstrate the class in a program. 2. TestScores Class Custom Exception Write an exception class named InvalidTestScore. Modify the Testscores class you wrote in Programming Challenge 1 so that it throws an InvalidTestscore exception if any of the test scores in the array are invalid.
Building on Lab Assignment 9 (TestScores Class Custom Exception), modify your code as follows: Read in an array of test scores from a file. If any of the test scores are invalid (via InvaidTestScore exception), then skip the invalid test score and continue to process your input file until an EOF (end-of-file); write out to a new (valid) data file. You may choose your input data file regarding values. For the File I/O, you should use: InputStream and OutputStream Classes. Only the Java code is needed for this assignment. Basic Example: File inputFile = new File("readTestScores.txt"); File outputFile = new File("writeTestScores.txt"); FilelnputStream fis = new FilelnputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile); For Reference (Lab 9 Assignment) 1. TestScores Class Write a class named Testscores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException. Demonstrate the class in a program. 2. TestScores Class Custom Exception Write an exception class named InvalidTestScore. Modify the Testscores class you wrote in Programming Challenge 1 so that it throws an InvalidTestscore exception if any of the test scores in the array are invalid.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
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.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning