Question
Java Projects: Concepts Tested in this Program : Error Handling Text I/O Project 12 consists of three small programs: Program 12_1: Write a program that
Java Projects:
Concepts Tested in this Program:
Error Handling
Text I/O
Project 12 consists of three small programs:
Program 12_1:
Write a program that prompts the user to read two integers and displays their sum . If anything but an integer is passed as input, your program should catch the InputMismatchException that is thrown and prompt the user to input another number by printing "Please enter an integer ."
Name your programs file as InputMismatch.java
SAMPLE RUN #1: java InputMismatch
Highlight: Show Highlighted Only
Enteraninteger:2.5?
Pleaseenteraninteger.?
Enteraninteger:4.6?
Pleaseenteraninteger.?
Enteraninteger:hello!?
Pleaseenteraninteger.?
Enteraninteger:7?
Enteraninteger:5.6?
Pleaseenteraninteger.?
Enteraninteger:9.4?
Pleaseenteraninteger.?
Enteraninteger:10?
17?
Program 12_2:
Write the bin2Dec (String binaryString) method to convert a binary string into a decimal number (your method should return an integer ). Implement the bin2Dec method to throw a NumberFormatException if the string is not a binary string. Test your method in a program that prompts the user to input a binary string and uses your bin2Dec method to print out the decimal equivalent of that string. If the method throws an error, have your program catch it and print "Not a binary string." before terminating.
Name your programs file as NumberFormat.java
SAMPLE RUN #1: java NumberFormat
Enterabinarystring:1011000101? 709?
Program 12_3:
Write a program that reads lines from a file and prints them out, removing all occurrences of a specified string from the lines. For example, if the class that housed your program was called RmvText, running this prompt on the command line: java RmvText John filename Would print out the contents of the file filename without any instances of the string John. Your program should get the arguments from the command line.
Name your programs file as RmvText.java
SAMPLE RUN #1: java RmvText going input
I'mtothemarket.?
How'sit??
Thingsaregreat.?
You'dbetterget!?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started