4 Replies - 536 Views - Last Post: 18 July 2011 - 09:51 PM Rate Topic: -----

#1 LieannM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-June 11

logic in creating a program regarding talent competition

Posted 16 July 2011 - 07:51 AM

how can i create a program using calling method about talent competition having 5 judges and 5 contestant. to get the average, i must drop the lowest and the highest score given by the 5 judges. i have a starting code but i dont think that im in a right path.

public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Scanner input = new Scanner(System.in);

        System.out.println("\t\t••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
        System.out.println("\t\t••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
        System.out.print("\t\t••\t\t\t\t\t\t\t\t\t  ");
        System.out.println("••");
        System.out.println("\t\t••\t\t\tWELCOME to Talent Competitions ☻ \t         ••");
        System.out.print("\t\t••\t\t\t\t\t\t\t\t\t  ");
        System.out.println("••");
        System.out.println("\t\t••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
        System.out.println("\t\t••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
        JudgeScore me = new JudgeScore();
         me.score(5);
       // getLowestHighestscore you = new getLowestHighestscore();
      //  you.lowesthighest(e,m);
      
    }
}
class JudgeScore{
    void score(int j){
            Scanner scan = new Scanner(System.in);
    double[] score = new double[5];
    System.out.println(" ");
    for (int y=1;y<=5;y++)
    {
        System.out.println(" ");
        System.out.println(" Please Enter The Score for Contestant #" + y + ":");
           for(int x=1;x<=j;x++)
           {
               System.out.print("\t Judge #" + x + ": ");
               score[x-1] = scan.nextDouble();
           }
  System.out.println("");
  System.out.print("\tGiven Score: ");
    for(int s=0;s<score.length;s++)
        {
            System.out.print(" "+score[s]);
        }
  System.out.println("");
    }

This post has been edited by LieannM: 16 July 2011 - 07:55 AM


Is This A Good Question/Topic? 0
  • +

Replies To: logic in creating a program regarding talent competition

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: logic in creating a program regarding talent competition

Posted 16 July 2011 - 09:07 AM

Why don't you think you're on the right path?
Was This Post Helpful? 0
  • +
  • -

#3 LieannM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-June 11

Re: logic in creating a program regarding talent competition

Posted 16 July 2011 - 09:12 AM

because i cannot pass the value from one class to another, and i dont know how will i going to compute the average .. because the output of this is continuously .. i mean from the 1st judge to the last judge i can enter the score but the problem is how will i separate those score for me to compute the average. by the way, computing the average is like dropping the lowest and the highest score then divide the remaining 3 score into 3.
Was This Post Helpful? 0
  • +
  • -

#4 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: logic in creating a program regarding talent competition

Posted 16 July 2011 - 09:28 AM

View PostLieannM, on 16 July 2011 - 12:12 PM, said:

because i cannot pass the value from one class to another, and

It's not clear where you need to do that, but you could keep all data entered in an array that is visible to all classes.

LieannM said:

i dont know how will i going to compute the average .. because the output of this is continuously .. i mean from the 1st judge to the last judge i can enter the score but the problem is how will i separate those score for me to compute the average. by the way, computing the average is like dropping the lowest and the highest score then divide the remaining 3 score into 3.

Have you learned arrays yet? Can you use arrays of arrays? If so, collect the scores in an array:

scores[numberOfContestants][numberOfJudges + 1]

Just a suggestion. You might think of a better way:
Determine the average for each contestant without the high and low score for each contestant, possibly using a method:

protected void calculateAverageWithoutHighAndLowScore( scores )
{
    // code that calculates the average of the scores remaining after throwing out
    // the high and low scores, storing the result in the last element of the array
    // for each contestant
}


If you're frustrated, overwhelmed, or in a time crunch, take a breath and break down the problem into small, manageable chunks that don't seem so formidable. Come back when you need more help or further clarification.

This post has been edited by GregBrannon: 16 July 2011 - 09:29 AM

Was This Post Helpful? 1
  • +
  • -

#5 LieannM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-June 11

Re: logic in creating a program regarding talent competition

Posted 18 July 2011 - 09:51 PM

JudgeScore theirscore = new JudgeScore();
      String [] Contnum1 = new String[5];

         String Cont1;
         System.out.print(" ");
         System.out.print("\t Enter Name: ");
         Cont1 = input.nextLine();
        Contnum1[0] = Cont1;
        double [] judge1 = new double[5];
            System.out.println("Contestant #1 " + Cont1 + " : ");
            theirscore.score(judge1);
            //theirscore.highest(judge1);
            //theirscore.lowest(judge1);


            [b]double largest = theirscore.highest(judge1);
            System.out.println("Highest Score is : " + largest );
            double min = theirscore.lowest(judge1);
            System.out.println("The Lowest Score is : " + min );
[/b]




    }

}

class JudgeScore{
    double[] score(double[] lima){
    Scanner scan = new Scanner(System.in);
    double[] score = new double[5];
    
          System.out.println(" Please Enter The Score: ");
           for(int x=1;x<=5;x++)
           {
               System.out.print("\t Judge #" + x + ": ");
               score[x-1] = scan.nextDouble();
           }
        
        return lima;
    }

    double highest(double[] high){
     double[] score = new double[5];

   System.out.println("");
  System.out.print("\tGiven Score: ");
    for(int s=0;s<score.length;s++)
        {
            System.out.print(" "+score[s]);
        }
  System.out.println("");

double largest=score[0];
for(int x=0; x<score.length; x++){
if(score[x]>largest){
largest = score[x];
}
}

//System.out.println(" "+largest);
    return largest;
    }

    double lowest(double[] low){
     double[] score = new double[5];
double min=score[0];
for(int x=1; x<score.length; ++x){
if(score[x]<min){
min = score[x];
}
}
//System.out.println(" "+min);

return min;


    }
}



i have this code but my problem is the function was not returning the right value :(
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1