Exercises 4. Using the IDE make a new project/program by changing SmallIO.java so that integers instead of...

50.1K

Verified Solution

Question

Programming

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 ;

  
}
  
  
  
  
  
  
  
}

Answer & Explanation Solved by verified expert
4.5 Ratings (634 Votes)
If you have any problem with the code feel free to commentihave highlighted the edited codesProgramimport javautilArrayListimport javautilCollectionsimport javautilScanner author MLpublic class Test public static void    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students