Exercises
4. Using the IDE make a new project/program by changingSmallIO.java so that integers instead of Strings are entered by theuser.
5. Change the program so that it only loops until the number-999 is entered by the user.
6. Modify the last program so that it (a) keeps and displays arunning total and the average so far of the entered numbers (b)displays the largest and the smallest numbers so far of the enterednumbers.
NOTE: PART 4 AND 5 HAS BEEN DONE. IN PART 6a TOTAL HAS BEEN DONEYOU HAVE TO CALCULATE AVERAGE AND DO PART B. BELOW IS THE PROGRAMCONTINUE DOING IT FROM WHERE I LEFT. THANKS
package tutorial1;
import java.util.Scanner;
/**
*
* @author ML
*/
public class Tutorial1 {
 Â
public static void main(String[] args) {
 Â
Scanner keyboard = new Scanner(System.in);
int a = 0; // initialise to empty string
int total = 0;
 Â
while (a != -999){
//an infinite loop, use Ctrl-C to quit
System.out.println(\"Enter a line:\"); //prompt
a= keyboard.nextInt(); ///accepts an integer
System.out.println(\"Your number: \" + a);
 Â
//method caLLS
total = totalaverage(a, total);
System.out.println(\"Your total is: \" + total);
 Â
System.out.println(); // print a blank line
} //end of while
 Â
 Â
}//end of main
// keeps and displays a running total and the average so far of theentered numbers
public static int totalaverage(int a, int total)
{
return total + a ;
 Â
}
 Â
 Â
 Â
 Â
 Â
 Â
 Â
}