Enter a number
Комментарии (14)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны sign in
danshy1803 Java Developer
23 March 2024, 09:05
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
+1
danshy1803 Java Developer
23 March 2024, 09:09
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!");
}
}
0
Vladyslav Boiko
17 June 2024, 19:13
why wasn't the first one working?
0
danshy1803 Java Developer
29 June 2024, 18:47
Scanner wasn't imported
+1
Anonymous #3045483
6 October 2024, 10:54
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 ;)
0
YaharpY
25 September 2023, 19:06
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
0
Anonymous #3315988
14 June 2023, 20:37
bruh
+3
Kirill
4 October 2022, 09:15
Did you suddenly forgot that you were teaching people and not just talking to yourself?
+10
Sergey
9 September 2022, 10:17
Why in the first excercise work ONLY second example from the previous lesson?
+1
Gerasim
31 August 2022, 12:32
Not enough information given in the previous lesson for completing the task! Amigo isn’t happy!
+3
nomadcoder Java Developer
10 June 2022, 01:34
Can you add explanation what does "throws Exception" means and why did we add it here?
+5
G QA Automation Engineer Expert
8 April 2022, 16:39
Why my text which exactly equal to hint's text do not pass the task condition?
+2
Andrei Nico
3 December 2021, 09:59
I don't understand what does the 'BufferedReader' and 'InputStreamReader' and why should we use them together...
+9
REM Backend Developer
13 December 2021, 19:53
This is a difficult topic. It's like learning English: you just have to remember first.
+2