The Program is running correctly but has not passed testing.

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 { InputStream inputStream = System.in; Reader inputStreamReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

    String n1 = bufferedReader.readLine();
    int num1 = Integer.parseInt(n1);
    String n2 = bufferedReader.readLine();
    int num2 = Integer.parseInt(n2);
    String n3 = bufferedReader.readLine();
    int num3 = Integer.parseInt(n3);

    double average;
    average = ((num1+num2+num3)/3);
    System.out.print(average);//add your code here
}

}

asked 14 Mar '15, 01:44

Rajat's gravatar image

Rajat
316
accept rate: 0%


I think that you wrong understans a task. Programme should print avarage number. Fro three number 2,4,3 it is 3, because 2 is the smallest , 4 is the biggest.

link

answered 14 Mar '15, 04:41

RabenokDmitry's gravatar image

RabenokDmitry
1263
accept rate: 14%

Program should display to the screen average number. Example first number "1"; second number "2"; third number "3"; to the screen displayed "2"

link

answered 14 Mar '15, 04:19

Joseph's gravatar image

Joseph
213
accept rate: 0%

public class Solution { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int b = scanner.nextInt(); int c = scanner.nextInt();

    int average = 0;
     if(a >=c  && a <= b || a <= c && a >= b)
     {
         average = a;
     } else if(b >= c&& b <= a || b <= c && b >= a)
     {
         average = b;
     } else if(c >= a && c <= b || c <= b && c >= a)
    {
        average = c;
    }
    System.out.println(average);
} }
link

answered 02 Apr, 07:26

TommyGuinness's gravatar image

TommyGuinness
11
accept rate: 0%

it seems work fine but not passing. Please help

(02 Apr, 07:27) TommyGuinness

Not pass. Please Help.

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String n1 = reader.readLine();
String n2 = reader.readLine();
String n3 = reader.readLine();
int a = Integer.parseInt(n1);
int b = Integer.parseInt(n2);
int c = Integer.parseInt(n3);
int sum = (a + b + c)/3;
System.out.print(sum);

link

answered 06 Jul, 08:45

blacklight's gravatar image

blacklight
11
accept rate: 0%

This code passed:

public static void main(String[] args)   throws Exception
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String n1 = reader.readLine();
        String n2 = reader.readLine();
        String n3 = reader.readLine();
        int a = Integer.parseInt(n1);
        int b = Integer.parseInt(n2);
        int c = Integer.parseInt(n3);

    if(a < b && a < c)
    {
        if (b < c)
        {
            System.out.println(b);
        } else
        {
            System.out.println(c);
        }
    }
    else if(a > b && a > c)
    {
        if (b < c)
        {
            System.out.println(c);
        }
        else
        {
            System.out.println(b);
        }
    }

    else if(b < a && b < c)
    {
        if (a < c)
        {
            System.out.println(a);
        } else
        {
            System.out.println(c);
        }
    }
    else if(b > a && b > c)
    {
        if (a < c)
        {
            System.out.println(c);
        }
        else
        {
            System.out.println(a);
        }
    }
}
link

answered 06 Jul, 09:21

blacklight's gravatar image

blacklight
11
accept rate: 0%

edited 07 Jul, 01:30

public class Solution

{ public static void main(String[] args) throws Exception

{
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String num1 = reader.readLine();
    String num2 = reader.readLine();
    String num3 = reader.readLine();
    int a = Integer.parseInt(num1);
    int b = Integer.parseInt(num2);
    int c = Integer.parseInt(num3);

    if (a < b AND a > c)
        System.out.print(a);

    else if (b < a AND b > c)
        System.out.print(b);

    else if (c < b AND c > a)
        System.out.print(c);

    else if (c < a AND c > b)
        System.out.print(c);
}

}

Replace AND with && and OK.

link

answered 24 Aug, 06:27

Demotivator's gravatar image

Demotivator
11
accept rate: 0%

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String n1 = reader.readLine(); String n2 = reader.readLine(); String n3 = reader.readLine(); int a = Integer.parseInt(n1); int b = Integer.parseInt(n2); int c = Integer.parseInt(n3); if(a>b && b>c) System.out.print(b); else if (b>a && a>c) System.out.print(a); else if (c>b && b>a) System.out.print(b);

    else if (a>c && c>b)
        System.out.print(c);

    else if (c>a && a>b)
        System.out.print(a);

    else if (b>c && c>a)
        System.out.print(c);
link

answered 21 Oct, 10:14

Aleksandra's gravatar image

Aleksandra
11
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
×3

Asked: 14 Mar '15, 01:44

Seen: 1,818 times

Last updated: 21 Oct, 10:14