10$ to anyone who makes me this Java program

We may earn a small commission from affiliate links and paid advertisements. Terms

94CivicSlow

Senior Member
write a program that prompts a user to enter 8 scores each containing 2 decimal places.

after the 8th score has been entered, add up the score, omitting the lowest and highest scores (ie 6 scores to be added) and output a msg indicating the amount of points.



:ph34r:
 
this is what i got

Code:
import java.util.*;

public class Score
{
static Scanner console = new Scanner(System.in);

public static void main (String[] args)

{

double[] list = new double[8];//create an array of 
int i, sum, counter;//8 components

System.out.println("Please enter the 8 recorded scores:");

sum = 0

for (i=0; i<list.length; i++)
list[i] = console.nextDouble();
 
fixed

Code:
import java.util.*;
import java.util.Arrays;

public class list
{
static Scanner console = new Scanner(System.in);

public static void main (String[] args)

{

double[] list = new double[8];//create an array of 
 //8 components
int i;
double sum; 
int counter;
int index; 
int maxIndex;
System.out.println("Please enter the 8 recorded scores:");
maxIndex = 0;

for (i=0; i<list.length; i++)
list[i] = console.nextDouble();
Arrays.sort(list); 

sum = (list[1] +list[2] + list[3] + list[4] + list[5] + list[6]);  
System.out.println("The result of highest and lowest trunication are: ");
System.out.println();

System.out.println(list[1]); 
System.out.println(list[2]); 
System.out.println(list[3]); 
System.out.println(list[4]); 
System.out.println(list[5]); 
System.out.println(list[6]); 
System.out.println();
System.out.println("The result of your scores is : " + sum);



}
}
 
Back
Top