MinAvg.java: Write a program that reads 10 integers and displays its minimum and average. Please consider the extreme case when all integers are positive. For instance, by given 1, 2, …, 10, the minimum will be 1.
import java.io.*;//imports all class from java.io package
import java.util.Scanner;//scanner class found in java.util
package
public class Main
{
public static void main(String[] args) {
int arr[]= new int[10]; //integer
array declaration
int i,a,min=0; //integer variable
declaration
float avg=0,total=0; //flaot
variable declaration
System.out.println("Enter the
numbers: ");
Scanner sc = new
Scanner(System.in);//Declaring sc as an object of scanner
class
for(i=0;i<10;i++)// loop for
user input
{
System.out.println("Enter a
positive integer:");
a=sc.nextInt();// input
if(a>0) //to consider only
positive input
{
arr[i]=a;//positive value is stored
in an array
}
else
{
i--;// else user input is taken
again and loop is decremented
System.out.println("Please enter
only positive numbers!");
}
}
min=arr[0]; //a value from the
array is stored in a variable
for(i=0;i<10;i++)//loop
{
if(arr[i]<min)//to check if it
is less than min
{
min=arr[i]; //if it is less than
min then min is changed with the new value
}
}
System.out.println("The minimum is
:"+min);//output
for(i=0;i<10;i++)//loop
{
total=total+arr[i];//to calculate
the total sum of all the array elements
}
avg=total/10;//average is
calculated
System.out.println("The average
is:"+avg);//display of average value
}
}
Screenshot of the code:
Screenshot of the Output:
MinAvg.java: Write a program that reads 10 integers and displays its minimum and average. Please consider...
Max3.java: Write a program that reads 10 integers and displays top 3 records (i.e., the largest three elements). Please consider the extreme case when all integers are negative. For instance, by given -1, -2, …, -10, the display will be -1, -2, and -3.
Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.
Write a program that reads k integers and displays their sum. Write a program that reads k values representing family income from the keyboard and place them into the array. Find the maximum income among these values. Count the families that make less than 10 percent of the maximum income. (JAVA)
Problem 1: Write a program that reads a positive float number and displays the previous and next integers. Sample Run: Enter a float: 3.5 The previous and next integers are 3 and 4. Problem 2: Write a program that reads two integers and displays their sum, difference, product, and the result of their division. Sample Run: Enter two integers: 8 5 Sum: 8, Difference: 3, Product: 40, Division: 1.6 Problem 3: Write a program that reads a three-digit integer from...
Write a C program which reads sets of two integers and displays them and their sum. Continue readings sets of integers until their sum is zero, at which point terminate the program.
I need to write a C++ program that reads two integers from a data filed called "integers.dat" The first integer should be low and the other one high. The program should loop through all integers between the low and high values and include the low and high integers and then display Display the integers in the file Displays the number of integers divisible by 5 OR 6, but not both. Displays the sum of the integers from condition 2 as...
(While-loop controlled by a sentinel value) Write a program that reads an unspecified number of integers. Your program ends with the input 0. Determine and display how many positive and negative values have been read, the maximum and minimum values, and the total and average of the input values (not counting the final 0).
Write a C++ program that reads a list of numbers 10 and displays largest, second largest and third largest. Note: Please do it with loops don't used arrays
Write a C program that reads a list of positive integers from a file named "input.txt." and count number of odd integers and even integers and prints the results to another file called "results.txt". Please submit both the input and results files along with the c program.
Q1. Write a C++ program that reads two integers a, and, b on the keyboard to calculate: U = (a + b)2 and V = (a - b)2 Q2. Write a C++ program to read a sequence of positive integers and to display the largest integer of that sequence. Use a negative integer to indicate the end of the data entry.