J
judith
I got my program to run except for one problem if you enter the same
score twice it won't add it into the sum of the scores. The divers
final score is supposed to be 67.5 and i'm getting 54.90 here's the
program again and the output. Sorry if i'm being repetive i'm just
wondering how to add the same score in twice. I would appreciate any
help or suggestions thanks Judith I won't post again on this one
output
C:\>java program5JS
Enter the degree of difficulty for the dive (1.2-3.8).
3.0
Enter score for judge 1 (0-10).
5
Enter score for judge 2 (0-10).
7
Enter score for judge 3 (0-10).
9
Enter score for judge 4 (0-10).
7
Enter score for judge 5 (0-10).
6.5
Enter score for judge 6 (0-10).
10
Enter score for judge 7 (0-10).
8
The diver's final score is 54.90
C:\>
Program
//Author: Judith Spurlock
//Course: ITSE 2437
//Program No: 5
//Due Date:
//Program Name: program5JS.java
import java.util.ArrayList;
import java.util.Scanner;
import java.text.DecimalFormat;
//fill in code
public class program5JS
{
public static void main(String[]args)
{
ArrayList<Double> scores = new ArrayList<Double>();
DecimalFormat pattern0dot00 = new DecimalFormat("0.00");
int posMinScore, posMaxScore;
double sum = 0;
double difficulty;
double finalScore;
Integer i;
Scanner keyboard = new Scanner(System.in);
//Input data values
System.out.println("Enter the degree of difficulty for the dive
(1.2-3.8).");
difficulty = keyboard.nextDouble();
//Input judges scores
double next = 0;
for (i = 1; i <= 7; i++)
{
System.out.println("Enter score for judge " + i + " (0-10).");
next = keyboard.nextDouble();
scores.add(next);
}
//Find position of min score
posMinScore = 0;
for(i = 1; i < scores.size(); i++)
{
if(scores.get(i) < scores.get(posMinScore))
posMinScore = i;
}
scores.remove(posMinScore);
//Find position of max score
posMaxScore = 0;
for(i = 1; i < scores.size(); i++)
{
if(scores.get(i) > scores.get(posMaxScore))
posMaxScore = i;
}
scores.remove(posMaxScore);
//sum scores
for(i = 1; i < scores.size(); i++)
{
sum = sum + scores.get(i);
}
//Calculate total score
finalScore = difficulty * sum * 0.6;
System.out.println("The diver's final score is "+
pattern0dot00.format(finalScore));
}
}
score twice it won't add it into the sum of the scores. The divers
final score is supposed to be 67.5 and i'm getting 54.90 here's the
program again and the output. Sorry if i'm being repetive i'm just
wondering how to add the same score in twice. I would appreciate any
help or suggestions thanks Judith I won't post again on this one
output
C:\>java program5JS
Enter the degree of difficulty for the dive (1.2-3.8).
3.0
Enter score for judge 1 (0-10).
5
Enter score for judge 2 (0-10).
7
Enter score for judge 3 (0-10).
9
Enter score for judge 4 (0-10).
7
Enter score for judge 5 (0-10).
6.5
Enter score for judge 6 (0-10).
10
Enter score for judge 7 (0-10).
8
The diver's final score is 54.90
C:\>
Program
//Author: Judith Spurlock
//Course: ITSE 2437
//Program No: 5
//Due Date:
//Program Name: program5JS.java
import java.util.ArrayList;
import java.util.Scanner;
import java.text.DecimalFormat;
//fill in code
public class program5JS
{
public static void main(String[]args)
{
ArrayList<Double> scores = new ArrayList<Double>();
DecimalFormat pattern0dot00 = new DecimalFormat("0.00");
int posMinScore, posMaxScore;
double sum = 0;
double difficulty;
double finalScore;
Integer i;
Scanner keyboard = new Scanner(System.in);
//Input data values
System.out.println("Enter the degree of difficulty for the dive
(1.2-3.8).");
difficulty = keyboard.nextDouble();
//Input judges scores
double next = 0;
for (i = 1; i <= 7; i++)
{
System.out.println("Enter score for judge " + i + " (0-10).");
next = keyboard.nextDouble();
scores.add(next);
}
//Find position of min score
posMinScore = 0;
for(i = 1; i < scores.size(); i++)
{
if(scores.get(i) < scores.get(posMinScore))
posMinScore = i;
}
scores.remove(posMinScore);
//Find position of max score
posMaxScore = 0;
for(i = 1; i < scores.size(); i++)
{
if(scores.get(i) > scores.get(posMaxScore))
posMaxScore = i;
}
scores.remove(posMaxScore);
//sum scores
for(i = 1; i < scores.size(); i++)
{
sum = sum + scores.get(i);
}
//Calculate total score
finalScore = difficulty * sum * 0.6;
System.out.println("The diver's final score is "+
pattern0dot00.format(finalScore));
}
}