Question: Task 1Recursive programming Write a program that prompts for and reads in a string, then prints a message saying how many lower case x is

Task 1Recursive programming Write a program that prompts for and reads in a string, then prints a message saying how many lower case x is in this string. Your program should contain two methods: a main method reads in the string and a recursive (static) method countX that takes the string as input and returns the number of lowercase character x in this string. Make sure your method solves the problem using a recursive way, not a loop structure. The following methods might be helpful, but you are not required to use all of them: For a string s in Java, ? s.length() returns the number of characters in s ? s.charAt(i) returns the ith character of s, 0-based ? s.substring(i,j) returns the substring that starts with the ith character of s and ends with the j-1st character of s (not the jth), both 0-based. So if s=happy, s.length=5, s.charAt(1)=a, and s.substring(2,4) = pp.

Task 2File Processing 1. Write a program to read in data from the given txt file source.txt. Use the throws clause to handle the IOException. Print out the data in the source.txt on the console window. 2. Add try-catch clauses into the program so in case the source.txt is not placed under the directory, your program will not crash. The message Input file is not found should be printed out. 3. Create an output stream to write the data into a txt file called destination.txt . For each line of the input data, you should add a line number when writing into destination.txt. For example: In source.txt Public static void main(String [] args) { System.out.println(This is a testing program); } The generated destination.txt should contain

Line 1: Public static void main(String [] args)

Line 2: {

Line 3: System.out.println(This is a testing program);

Line 4: }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!