CodeGym
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
CodeGym/Help with Java Tasks/whats wrong with this solution . it display the correct a...
Jaisingh
Level 14
Hyderabad
  • 15.09.2018
  • 1912views
  • 2comments

whats wrong with this solution . it display the correct answer . but server is not accepting it . plz tell me whats mistake

Question about the task Minimum of two numbers
Java Syntax,  Level 4,  Lesson 6
Under discussion


Use the keyboard to enter two integers, and display the minimum. If the two numbers are equal, display either of them.

Requirements:
  • The program should read the numbers from the keyboard.
  • The program must display a number on the screen.
  • The program should display the minimum of two integers.
  • If the two numbers are equal, display either of them.
package com.codegym.task.task04.task0418; /* Minimum of two numbers */ import java.io.*; public class Solution { public static void main(String[] args) throws Exception { //write your code here //REad input from the keyboard BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in)); String num1 = bfr.readLine(); String num2 = bfr.readLine(); int a = Integer.parseInt(num1); int b = Integer.parseInt(num2); findMininum(a, b); } public static void findMininum (int a, int b) { if (a < b) System.out.println(a); else if (a == b) System.out.println(a + " " + b); else System.out.println(b); } }
+2
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Jaisingh
Level 14 , Hyderabad, India
15 September 2018, 18:59
i thought to print both of them as he said either of them instead either one of them
+1
Khurram
Level 16 , Lahore, Pakistan
15 September 2018, 05:16useful
if the two numbers are the same, you should display only one of them, not both.
+1
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2025 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2025 CodeGym