import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new
Scanner(System.in);
int arr[] = new int[10];
int i,count=0;
double sum=0.0;
System.out.print("Enter 10
integers: \n");
for(i=0;i<10;i++)
arr[i] = sc.nextInt();
for(i=0;i<10;i++)
{
if(arr[i]>=0)
sum=sum+arr[i];
}
for(i=0;i<10;i++)
{
if(arr[i]==0)
count++;
}
if(sum==0&&count==0)
System.out.print("There are no positive
values.");
else
{
System.out.printf("The sum of positive numbers is
%.0f\n",sum);
System.out.println("The average of positive numbers is "
+sum/10);
}
}
}
Task 1 : Write a Java program that prompts for and reads 10 integers from the...
A java program Write a program that prompts for and reads in a positive integer into a variable n. Your program should then sum the first n ODD integers and display the sum. For example, if 3 is entered for n, your program should display the the sum 1 + 3 + 5. If 5 is entered, your program should display the sum 1 + 3 + 5 + 7 + 9. What is the...
I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...
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)
C++
Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...
In Java
Write a program that reads an arbitrary number of 25 integers that are positive and even. The program will ask the user to re-enter an integer if the user inputs a number that is odd or negative or zero. The inputted integers must then be stored in a two dimensional array of size 5 x 5. Please create 3 methods: 1. Write a method public static int sum2DArray( int [1] inputArray ) The method sums up all elements...
in java
3) Sum. Write a program that prompts the user to read two integers and displays their sum. Your program should prompt the user to read the number again if the input is incorrect.
In Java*
Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...
IN JAVA 1. Create a program that prompts the user for an integer and then displays a message indicating whether or not the number is a perfect square. This can be determined by finding the square root of a number, truncating it (by casting the double result), and then squaring that result 2. Write a program that prompts the user for two numbers. The first number is a minimum value and the second number is a maximum value. RandomNum then...
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...
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.