Java Assignment

1. 1. Write a complete Java program called CharCounter that gets a two Strings called word and character from the user at the command line and then counts the occurrences of character in word. Check that character has a length of 1, and then extract the char. Use a while loop to check each position in the word String variable and return the number of times the char occurs. For example, if word is test and character is e you would output: There is 1 occurrence of e in test. (2 points)1. 2. Write a complete Java program called Rooter that gets a positive integer called start from the user at the command line and then finds the square root of every number from start DOWN to zero. Use a while loop to count down. Print each square root on a separate line. Hint: you can use the Math.sqrt(double a) method to find the square roots. (3 points) 1. 3. Write a complete Java program called Averager to get positive numbers (doubles) from the user at the command line until they enter -1 (the sentinel). Use do-while for your loop. Compute the average of the series of numbers and print the average to the command line. (2 points)1. 4. Write a Java program called PowTable that uses nested for loops to print a table of the numbers 1 through 9 raised to the 2nd, 3rd, and 4th power. Review the Math.pow(double, a, double b) method. See the example below. Use the outer and inner loop counters as the arguments to Math.pow(). Make sure to include the row and column headings. (3 points) 2 3 4 1 1.0 1.0 1.0 2 4.0 8.0 16.0 3 9.0 27.0 81.0 4 16.0 64.0 256.0 5 25.0 125.0 625.0 6 36.0 216.0 1296.0 7 49.0 343.0 2401.0 8 64.0 512.0 4096.0 9 81.0 729.0 6561.0