JavaRush /Courses /New Java Syntax /Enter a number

Enter a number

New Java Syntax
Level 2, Lesson 8
Available
Enter a number - 1

"Hi, Amigo. You're doing great. Here is a new exercise for you: write a program that accepts some data from the keyboard and displays text that uses that data:"

2
Task
New Java Syntax, level 2, lesson 8
Locked
How to take over the world
How to take over the world
2
Task
New Java Syntax, level 2, lesson 8
Locked
Predictions
Predictions
2
Task
New Java Syntax, level 2, lesson 8
Locked
Deep and pure love
Deep and pure love
Comments (14)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
danshy1803 Level 21
23 March 2024
Scanner scanner = new Scanner(System.in); String name = scanner.nextLine(); int number = scanner.nextInt(); System.out.println(name + " will take over the world in " + number + " years. Mwa-ha-ha!"); Doesn't work and I don't know why
danshy1803 Level 21
23 March 2024
Nvm, figured that out, here's the code for everyone strugglin: package en.javarush.task.jdk13.task03.task0318; import java.io.BufferedReader; import java.io.InputStreamReader; /* How to take over the world */ public class Solution { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String name = reader.readLine(); String sNumber = reader.readLine(); int number = Integer.parseInt(sNumber); System.out.println(name + " will take over the world in " + number + " years. Mwa-ha-ha!"); } }
17 June 2024
why wasn't the first one working?
danshy1803 Level 21
29 June 2024
Scanner wasn't imported
6 October 2024
you dont even need to parse int from the input text because there is no need in representation of it as a number. System.out.println wants a string, and you can leave it a String, without making unnecessary transformations ;)
YaharpY Level 14
25 September 2023
well, the first task is definitely not for level 2... It was a poor explanation in the lesson, so there is close to no chance of completing the task without additional research
14 June 2023
bruh
Kirill Level 3
4 October 2022
Did you suddenly forgot that you were teaching people and not just talking to yourself?
Sergey Level 23
9 September 2022
Why in the first excercise work ONLY second example from the previous lesson?
Gerasim Level 2
31 August 2022
Not enough information given in the previous lesson for completing the task! Amigo isn’t happy!
nomadcoder Level 3
10 June 2022
Can you add explanation what does "throws Exception" means and why did we add it here?
G Level 41 Expert
8 April 2022
Why my text which exactly equal to hint's text do not pass the task condition?
Andrei Nico Level 5
3 December 2021
I don't understand what does the 'BufferedReader' and 'InputStreamReader' and why should we use them together...
REM Level 12
13 December 2021
This is a difficult topic. It's like learning English: you just have to remember first.