
how do i write a program that will prompt the user for a list of 5 prices, once the user has entered all values , your program should compute and display the following: The sum of all the prices, The average of the prices, All prices that higher than the calculated average

import java.util.*;
class Price{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter prices: ");
double prices[]=new double[5];
int sum=0;
for(int i=0;i<prices.length;i++){
prices[i]=input.nextDouble();
}
for(int i=0;i<prices.length;i++){
sum+=prices[i];
}
System.out.println("Sum of all prices: "+sum);
double average=sum/prices.length;
System.out.println("Average of all prices: "+average);
System.out.println("Prices that are larger than the average: ");
for(int i=0;i<prices.length;i++){
if(prices[i]>average){
System.out.println(prices[i]);
}
}
}
}

import java.util.*;
class Price{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter prices: ");
double prices[]=new double[5];
int sum=0;
for(int i=0;i<prices.length;i++){
prices[i]=input.nextDouble();
}
for(int i=0;i<prices.length;i++){
sum+=prices[i];
}
System.out.println("Sum of all prices: "+sum);
double average=sum/prices.length;
System.out.println("Average of all prices: "+average);
System.out.println("Prices that are larger than the average: ");
for(int i=0;i<prices.length;i++){
if(prices[i]>average){
System.out.println(prices[i]);
}
}
}
}

import java.util.*;
class Price{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter prices: ");
double prices[]=new double[5];
int sum=0;
for(int i=0;i<prices.length;i++){
prices[i]=input.nextDouble();
}
for(int i=0;i<prices.length;i++){
sum+=prices[i];
}
System.out.println("Sum of all prices: "+sum);
double average=sum/prices.length;
System.out.println("Average of all prices: "+average);
System.out.println("Prices that are larger than the average: ");
for(int i=0;i<prices.length;i++){
if(prices[i]>average){
System.out.println(prices[i]);
}
}
}
}

import java.util.*;
class Price{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter prices: ");
double prices[]=new double[5];
int sum=0;
for(int i=0;i<prices.length;i++){
prices[i]=input.nextDouble();
}
for(int i=0;i<prices.length;i++){
sum+=prices[i];
}
System.out.println("Sum of all prices: "+sum);
double average=sum/prices.length;
System.out.println("Average of all prices: "+average);
System.out.println("Prices that are larger than the average: ");
for(int i=0;i<prices.length;i++){
if(prices[i]>average){
System.out.println(prices[i]);
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.