There are three independent programs to implement Please use
There are three independent programs to implement. Please use multbpe t. Please use multiple test samples to ensure the correctness of your programs. Make sure each program compu E runs. Place only the java files in your Dropbox in a folder named Lab 72 by Frday October 28, 2016 at midnight piles and 7_2 by Friday, 1) Write a program that reads three strings from the user. Although the strings are in no particular order, display the string that would be second if they were arranged lexicographically. Two examples are shown: Please enter three words separated by spaces orange peach apple The middle word is orange. Please enter three words separated by spaces Cops Cups Cubs The middle word is Cubs. 2) Write a program to read a list of nonnegative integers and display the count, the total, and the average of all the valid input integers. The user indicates the end of input by entering a negative sentinel value. The average should be a value of type double so it is computed with a fractional part. ,\"lease input alistofnonnegativeintegernumbersendingwith-1: Please input a list of nonnegative integer numbers ending with -1: 56 23 81 11 674-1 There are 6 integers. The total is 251, and the average is 41.8333 3) Write a program to count the number of blank characters in a given string. Ask the user to input a sentence, and display the number of blank characters in the sentence. Assume there is no space before the first word, and no space after the last word of a
Solution
import java.util.*;
public class Program {
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
System.out.println(\"Please enter a list\" +
\" of positive integers\");
System.out.println(\"and lastly, enter a \" +
\"negative number:\");
int input = 0;
int sum = 0;
int count = 0;
while ((input =scanner.nextInt()) >= 0) {
sum += input;
count ++;
}
System.out.println(\"\ There are \"+count+\"integers\");
System.out.println(\"\ The total is \"+sum);
System.out.println(\"\ Average: \"+ ((double) sum / count));
}
}
