Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

it is not compiling

+5 votes
asked Sep 25 by Gopi Krishna (310 points)
import java.util.*;
class racdemo
{
  public static void main(String args[])
  {
    Float n1,n2,n3,n4,n5,avg;
  Scanner s=new Scanner(System.in);
    n1=s.nextFloat();
    System.out.println("eneter the first racer");
    n2=s.nextFloat();
   System.out.println("enter the second racer");
    n3=s.nextFloat();
    System.out.println("enyter the third racer");
    n4=s.nextFloat();
    System.out.println("enter the fourth racer");
    n5=s.nextFloat();
    System.out.println("enter the fifth racer");
    avg=n1+n2+n3+n4+n5/5;
    System.out.println("averaage"+avg);
    if(n1>avg)
      System.out.println("1st racer winner");
    else if(n2>avg)
      System.out.println("2nd racer winner");
    else if(n3>avg)
      System.out.println("3rd racer winner");
    else if(n4>avg)
      System.out.println("4th racer winner");
    else if(n5>avg)
      System.out.println("5th racer winner");
  }
}

3 Answers

+1 vote
answered Sep 25 by xDELLx (10,360 points)
selected Sep 26 by Gopi Krishna
 
Best answer
import java.util.*;

class Main // Not class racdemo
{
    public static void main(String args[])
    {   
        //Your code as usual..
    }
}

Looks like Online compiler only works with class Main.

0 votes
answered Sep 25 by Arpitpathak24 (140 points)

import java.util.Scanner;
class racdemo
{
  public static void main(String args[])
  {
    Float n1,n2,n3,n4,n5,avg;
  Scanner s=new Scanner(System.in);
    n1=s.nextFloat();
    System.out.println("eneter the first racer");
    n2=s.nextFloat();
   System.out.println("enter the second racer");
    n3=s.nextFloat();
    System.out.println("enyter the third racer");
    n4=s.nextFloat();
    System.out.println("enter the fourth racer");
    n5=s.nextFloat();
    System.out.println("enter the fifth racer");
    avg=n1+n2+n3+n4+n5/5;
    System.out.println("averaage"+avg);
    if(n1>avg)
      System.out.println("1st racer winner");
    else if(n2>avg)
      System.out.println("2nd racer winner");
    else if(n3>avg)
      System.out.println("3rd racer winner");
    else if(n4>avg)
      System.out.println("4th racer winner");
    else if(n5>avg)
      System.out.println("5th racer winner");
  }
}

0 votes
answered Sep 26 by santosh (140 points)
import java.util.*;

class Racdemo

{

static float n1,n2,n3,n4,n5,avg;

  public static void main(String args[])

  {

  Scanner s=new Scanner(System.in);

    n1= s.nextFloat();

    System.out.println("eneter the first racer");

    n2=s.nextFloat();

   System.out.println("enter the second racer");

    n3=s.nextFloat();

    System.out.println("enyter the third racer");

    n4=s.nextFloat();

    System.out.println("enter the fourth racer");

    n5=s.nextFloat();

    System.out.println("enter the fifth racer");

    avg=(n1+n2+n3+n4+n5)/5;

    System.out.println("averaage"+avg);

    if(n1>avg)

      System.out.println("1st racer winner");

    else if(n2>avg)

      System.out.println("2nd racer winner");

    else if(n3>avg)

      System.out.println("3rd racer winner");

    else if(n4>avg)

      System.out.println("4th racer winner");

    else if(n5>avg)

      System.out.println("5th racer winner");

  }

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...