CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Start learning now
  • All questions
satya vath
Level 9
Mumbai
  • 20.11.2018
  • 1113views
  • 6comments

Why amn't I satisfying with the last condition

Question about the task Fixing the mistakes of youth
Java Syntax,  Level 6,  Lesson 11
Resolved

Task: The program takes two numbers from the keyboard and displays the maximum using a phrase like "The max is 25".

Requirements:
  • The program must read data from the keyboard.
  • The program should display the result on the screen.
  • The displayed text should start with "The max is".
  • The displayed text should end with the maximum of the 2 entered numbers.
package com.codegym.task.task06.task0620; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* Fixing the mistakes of youth */ public class Solution { public static int max = 100; public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String max = "The max is "; int a = Integer.parseInt(reader.readLine()); int b = Integer.parseInt(reader.readLine()); String fgGF = reader.readLine(); int satya = Integer.parseInt(fgGF); // int satya; //int a = 89; //int b = 88; satya = a > b ? a : b; System.out.println(max + satya); } }
0
Comments (6)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
satya vath
Level 9 , Mumbai, India
22 November 2018, 01:24
Thank you i have solved it
0
satya vath
Level 9 , Mumbai, India
21 November 2018, 02:02
i have kept it because i need anoher variable to make the code print
0
Michael Martin
Level 19 , Arlington, United States
21 November 2018, 14:56
Ok. But you are using that variable to read a string via readLine(); There should only be two inputs to the program (both ints)
0
satya vath
Level 9 , Mumbai, India
20 November 2018, 15:15
micheal can you say the answer
0
Michael Martin
Level 19 , Arlington, United States
20 November 2018, 16:18
Just telling you the answer doesn't help you. In your code why do you have this line: String fgGF = reader.readLine();
0
Michael Martin
Level 19 , Arlington, United States
20 November 2018, 14:58
Why are you doing 3 readLine() method calls? You only need to input 2 numbers.
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • 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 Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.