Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE USE JUST BASIC COMPILER ONLY : Write a program to ask the user as to how

ID: 3757645 • Letter: P

Question

PLEASE USE JUST BASIC COMPILER ONLY :

Write a program to ask the user as to how many numbers they want to enter.
your program should collect that many numbers from the user and find the smallest and Average of those numbers.

For example, if the user says, he/she wants to enter 6 numbers, you should collect 6 numbers. You can accomplish this by looping 6 times, collecting one number each time you are in the loop.

Hint1: You can use the while..wend loop to write this program
Hint2: Study the program which calculates the largest of the 10 numbers.

Explanation / Answer

import java.util.*;

public class Sma

{

public static void main(String args[])

{

int inputNumber,sum,count,average;

sum=0;

count=0;

System.out.println("Enter the first positive integer");

inputNumber=TextIO.getlnInt();

while(inputNumber!=0)

{

sum+=inputNumber;

count++;

System.out.println("Enter next positive integer");

inputNumber=TextIO.getlnInt();

}

if(count==0)

{

System.out.println("No data is entered!");

}

else

{

average=(sum)/count;

System.out.println();

System.out.println("You entered"+count+"positive integers");

System.out.println("Their average is:"+average);

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote