Results 1 to 5 of 5

Thread: Help me pls.

  1. #1
    pinar is offline Member
    Join Date
    Oct 2010
    Posts
    10
    Rep Power
    0

    Exclamation Help me pls.

    /*(Finding the two highest scores) Write a program that prompts the user
    to enter the number of students and each student's name and score,
    and finally displays the student
    with the highest score and the student with the second-highest score.*/
    I dont know it how Do ı do:S

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Break the big problem down into smaller problems and solve each one individually. For instance first work on getting the input from the user. Then work on checking which is highest and second highest, and finally work on displaying out put.

    You should try as much as possible on your own, and post your attempt here. Then ask specific questions if possible. Please see the last link in my signature for more on creating a new program when you don't know how. Much luck!

  3. #3
    pinar is offline Member
    Join Date
    Oct 2010
    Posts
    10
    Rep Power
    0

    Default

    Java Code:
    Scanner sc=new Scanner(System.in);
    int max=0;
    String name="";
    int score=0;
    int no=0;
    int maxno=0;
    String bigname="";
    //String ıkıncıbuyukad="";
    for(int i=1;i<=3;i++)
    {
    System.out.println("ad gir");
    name=sc.next();
    System.out.println("numara gir");
    no=sc.nextInt();
    System.out.println("puan gir");
    score =sc.nextInt();}
    
    if(score>max)
    {
    max=score;
    bigname=name;
    maxno=no;
    }
    }
    System.out.println(max,"",maxno,"",bigname)
    I wanted user who have max score I wrote this code but it didnt work.
    Last edited by Fubarable; 10-31-2010 at 10:12 PM. Reason: Moderator edit: code tags added

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by pinar View Post
    I wanted user who have max score I wrote this code but it didnt work.
    Please tell us how it doesn't work. Does it show any error messages? Does it show the wrong out put?

    Also, please post formatted code with indentations, and use code tags -- which I've added to your code above (see my first signature link to see how to do this).

    edit: also, this line doesn't compile, does it?
    Java Code:
    System.out.println(max,"",maxno,"",bigname)
    Much luck!
    Last edited by Fubarable; 10-31-2010 at 10:20 PM.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •