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
315
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
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:

×35
×8
×3

Asked: 14 Mar '15, 01:44

Seen: 1,333 times

Last updated: 02 Apr, 07:27