Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. In java Create a class called ExceptionPractice which includes a main method. The program asks user to enter a string. If the string is

1. In java Create a class called ExceptionPractice which includes a main method. The program asks user to enter a string. If the string is empty, it throws a EmptyStringException. The program handles the exception by printing an error message. If the string is not empty, the program converts the string to uppercase and prints it.

You also need to write a class called EmptyStringException. It should extend the Exception class. Include two constructors, the default constructor and a one-parameter constructor (where the parameter type should be String).

Include your code for both ExceptionPractice class and EmptyStringException class below.

2. Create a class called FileInputOutputPractice which includes the main method. The program reads line by line from an input file (named as "activity5_input.txt"), adds line number at the beginning of each line and converts each line to uppercase, and then writes to a separate file called "activity5_output.txt". Make sure you include exception handling code for file I/O. Also make sure to include "import java.io.*;" statement.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions