ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2056. Scholarship

Why i get "Wrong answer"?
Posted by Sagamore 12 Jul 2017 17:49
//I have correct in the IDE, what's wrong?

import java.io.IOException;
import java.util.Scanner;

public class VasyaCare{
    public static void main(String[] args) throws IOException {
    VasyaCare vasya_care = new VasyaCare();
    Scanner scn = new Scanner(System.in);
    int n = scn.nextInt();
    try{                               // Check
            if(n < 10){
        double[] b = vasya_care.setScore(n);
        double median = vasya_care.getMedian(b);
        if(median==3){
            System.out.println("None");
        }
        else if(median==5){
            System.out.println("Named");
        }
        else if(median >= 4.5){
            System.out.println("High");
        }
        else if(median < 4.5){
            System.out.println("Common");
        }
        }
        else throw new IOException("Please, type number from 1 to 10!");
    }
    catch(Exception e){e = new IOException();}
    }


    double getMedian(double[] b{          // calculate median score of exam
    int sum = 0;
    for(int i = 0; i < b.length; i++){
        sum = (int) (sum + b[i]);
    }
    return (double)sum/b.length;
    }

    double[] setScore(int n){            // forming list scores
    Scanner scn = new Scanner(System.in);
    double[] b = new double[n];{
        for(int j = 0; j < n; j++){
            int m = scn.nextInt();
            if(m<3 || m > 5){
                System.out.println("Type score from 3 to 5: ");
                j--;
            }
            else if (m>=3 && m<=5){
                b[j] = m;
            }
        }
    }
    return b;
    }
}

// Thank you for your attention!
Re: Why i get "Wrong answer"?
Posted by Mahilewets 12 Jul 2017 19:17
If Vasya has at least one note 3 scholarship is 'None'.
So, 355555555... is no scholarship.
Sorry if you considered that,  I have read your code very careless.
Re: Why i get "Wrong answer"?
Posted by Sagamore 12 Jul 2017 21:47
You're wrong, sorry, there is my testing:

Input
Type number exam:
8

Type score:
3
Type score:
5
Type score:
5
Type score:
5
Type score:
5
Type score:
5
Type score:
5
Type score:
5
3.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 average score: 4.75

Output:
High

I really don't understand, what's wrong. ((
Re: Why i get "Wrong answer"?
Posted by Mahilewets 13 Jul 2017 01:23
I have just copied code from my Accepted submissions.
http://ideone.com/vWEL58
I think the problem is easy enough
To let post AC code be legal.
Re: Why i get "Wrong answer"?
Posted by Mahilewets 13 Jul 2017 01:26
So there correct answer is "None"  and dialog interface is not needed.  Moreover, in most cases,there should be no  dialog interface to get AC.
Re: Why i get "Wrong answer"?
Posted by Sagamore 13 Jul 2017 09:51
You have "none" because your case "cur=int (input ()) if cur==3:..." does not check for the average score and passes at runtime immediately. You must check the average score in all cases, not the input variable.
Re: Why i get "Wrong answer"?
Posted by Mahilewets 13 Jul 2017 10:41
Are you a troll?
That is Accepted code.
If you copy &  paste you AC.