# java

shekhar dipti
java
Posted in : Java Beginners
Q: In a certain diving even a score is awarded by each of the 10 judges.
the highest and the lowest score are neglected and the average of the rest
is found to get the final score. Design a flochart to input the 10 score.
There is only one highest acore and the lowest score.

January 14, 2010 at 2:42 PM

Hi Friend,

Try the following code:

import java.util.*;
class Calculate{
public static int[] deleteFromArray(int index, int[] arr, int value){
boolean [] deleteNumber = new boolean[arr.length];
int size=0;
for(int i=0;i<arr.length;i++){
if(arr[i]==value){
deleteNumber[i]=true;
}
else{
deleteNumber[i]=false;
size++;
}
}
int[] newArr=new int[size];
int in=0;
for(int i=0;i<arr.length;i++){
if(!deleteNumber[i]){
newArr[in++]=arr[i];
}
}
return newArr;
}
public static void main(String[] args){
int sum=0;
int arr[]=new int[10];
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
int j=0,k=0;

Scanner input=new Scanner(System.in);
System.out.println("Enter 10 numbers:");
for(int i=0;i<arr.length;i++){
arr[i]=input.nextInt();
if (arr[i] < min) {
min = arr[i];
j=i;
}
if (arr[i] > max) {
max = arr[i];
k=i;
}
}
System.out.println("Minimum="+min);
System.out.println("Maximun="+max);
int newArr[]=Calculate.deleteFromArray(j,arr,min);
int finalArr[]=Calculate.deleteFromArray(k,newArr,max);
for(int i=0;i<finalArr.length;i++){
sum+=finalArr[i];
}
System.out.println("Final Score: "+sum);
int average=sum/10;
System.out.println("Average Score: "+average);

}

}

Thanks

java
java  diff bt core java and java
java
java  what is java
java
java  explain technologies are used in java now days and structure java
java
java  different between java & core java
JAVA
JAVA  how the name came for java language as "JAVA
java
java   why iterator in java if we for loop
Java
Java   Whether Java is pure object oriented Language
java
java  is java open source
java
java  what is java reflection
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   What is ?static? keyword
java
java  RARP implementation using java socket
java
java  sample code for RARP using java
java
java  give a simple example for inheritance in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  Write a java code to print "ABABBABCABABBA
java
java  write a program in java to acess the email
java
java  send me java interview questions
java
java  is java purely object oriented language
java
java  write a java program using filenotfoundexception
java
java  Does java allows multiline comments
Java
Java  how to do java in command prompt
java
java  give a simple example for inheritance in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  how use java method
java
java  what are JAVA applications development tools
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  why multiple inheritance is not possible in java