Monday, March 5, 2012
Challenge 042: Is There A Curve?
import java.util.Scanner;
import java.util.Arrays;
public class IsThereACurve
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.print(" # of Students ");
int n = scan.nextInt();
int [] scores = new int[n];
for ( int i = 0; i < scores.length; i++)
{
System.out.println( "Score: " + (i + 1));
scores[i] = scan.nextInt();
}
Arrays.sort(scores);
System.out.println("Current Score: ");
for(int x = 0; x <= scores.length - 1; x++)
{
System.out.println(scores[x]);
}
System.out.println();
curvedScores(scores);
}
public static void curvedScores(int [] s)
{
int[] newScores = s;
Arrays.sort(newScores);
int curve = 100 - newScores [newScores.length - 1];
System.out.println("Curved Scores:");
for(int x = 0; x <= s.length - 1; x++)
{
System.out.println((s[x] + curve));
}
}
}
Subscribe to:
Post Comments (Atom)
Good work here, 600 XPs awarded for this completion.
ReplyDelete