My code works in Intelij IDEA correctly but it hasn`t passed testing.Why?

package com.javarush.test.level04.lesson16.home02;

import java.io.*;

/ Display an average Write a program that reads from keyboard three numbers. The program should display to the screen the average of these numbers, that is, neither the biggest nor the smallest one. /

public class Solution { public static void main(String[] args) throws Exception { //add your code here BufferedReader klava = new BufferedReader(new InputStreamReader(System.in)); String s = klava.readLine(); String g = klava.readLine(); String v = klava.readLine(); float first = Float.parseFloat(s); float second = Float.parseFloat(g); float third = Float.parseFloat(v); float average = 0; if(first >= third && first <= second || first <= third && first >= second){ average = first; } else if(second >= third && second <= first || second <= third && second >= first){ average = second; } else if(third >= first && third <= second || third <= second && third >= first){ average = third; } System.out.println(average); } }

asked 11 Jan, 15:05

Morkovkins%20Channel's gravatar image

Morkovkins C...
1
accept rate: 0%


Sorry, repaste the code`` :

BufferedReader klava = new BufferedReader(new InputStreamReader(System.in));
    String s = klava.readLine();
    String g = klava.readLine();
    String v = klava.readLine();
    float first = Float.parseFloat(s);
    float second = Float.parseFloat(g);
    float third = Float.parseFloat(v);
    float average = 0;
    if(first >= third && first <= second || first <= third && first >= second){
       average = first;
    }
    else if(second >= third && second <= first || second <= third && second >= first){
       average = second;
    }
    else if(third >= first && third <= second || third <= second && third >= first){
        average = third;
    }
    System.out.println(average);
link

answered 11 Jan, 15:17

Morkovkins%20Channel's gravatar image

Morkovkins C...
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×36
×8
×1

Asked: 11 Jan, 15:05

Seen: 322 times

Last updated: 11 Jan, 15:17