package com.codegym.task.task03.task0318;
/*
Plan to conquer the world
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
InputStream inputStream = System.in;
Reader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader b = new BufferedReader(inputStreamReader);
System.out.println("Enter a name");
String s = b.readLine();
System.out.println("Enter year");
String c = b.readLine();
int n = Integer.parseInt(c);
System.out.println(s+" will take over the world in "+n+" years. Mwa-ha-ha!");
}
}
it says "Be sure that you haven't mixed up the order of reading in the name and number from the keyboard. Check the conditions." what's wrong with my code?
Resolved
Comments (22)
- Popular
- New
- Old
You must be signed in to leave a comment
Tayyab Mubeen
31 October 2018, 18:54
remove line number 16 and 18
no need....!!!
also change variable s with name..!!
and n with number....!!!
remove line number 13 and 14...!! its a long way to take input try a single line code this will save your time
modify your line number 15...!!!!
hope this help...!!! 0
Harika Yantrapragada
31 October 2018, 19:03
even these modifications gives same output.
It shows that there is an error in input order
0
Harika Yantrapragada
31 October 2018, 19:06
Compiler output
cannot find symbol symbol: class inputStreamReader location: class com.codegym.task.task03.task0318.Solution:
Solution.java, line: 13, column: 51
Here's the compiler output:
com/codegym/task/task03/task0318/Solution.java:13: error: cannot find symbol
BufferedReader b = new BufferedReader(new inputStreamReader(System.in));
^
symbol: class inputStreamReader
location: class com.codegym.task.task03.task0318.Solution
0
Harika Yantrapragada
31 October 2018, 19:11
package com.codegym.task.task03.task0318;
/*
Plan to conquer the world
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader b = new BufferedReader(new inputStreamReader(System.in));
String s = b.readLine();
String a = b.readLine();
int n = Integer.parseInt(a);
System.out.println(s + " will take over the world in " + n + " years. Mwa-ha-ha!");
}
}
0
Tayyab Mubeen
31 October 2018, 19:12
the compiler is showing error because you used inputStreamReader
but you need this
InputStreamReader
0
Tayyab Mubeen
31 October 2018, 19:14
mark it resolved...!!!
0
Harika Yantrapragada
31 October 2018, 19:14
still getting an error
The displayed text must fully match the task conditions.
RECOMMENDATION FROM YOUR MENTOR
Be sure that you haven't mixed up the order of reading in the name and number from the keyboard. Check the conditions.
0
Tayyab Mubeen
31 October 2018, 19:15
change the variable names...
you should use name and number
0
Harika Yantrapragada
31 October 2018, 19:19
even that's giving the same error
0
Tayyab Mubeen
31 October 2018, 19:21
why are you using number in print statement when you are using int numa...???
by the way what is numa...?
try use
0
Merima
31 October 2018, 19:23
still not working ...
0
Harika Yantrapragada
31 October 2018, 19:23
that's what i have tried but there is an error
Be sure that you haven't mixed up the order of reading in the name and number from the keyboard. Check the conditions.
0
Tayyab Mubeen
31 October 2018, 19:24
also check your spaces...!!! you got wrong out put merima...!!!
0
Tayyab Mubeen
31 October 2018, 19:26
0
Tayyab Mubeen
31 October 2018, 19:27
show code
0
Harika Yantrapragada
31 October 2018, 19:28
package com.codegym.task.task03.task0318;
/*
Plan to conquer the world
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
String name = b.readLine();
int num = Integer.parseInt(b.readLine());
System.out.println(name + " will take over the world in " + num + " years. Mwa-ha-ha!");
}
}
0
Merima
31 October 2018, 19:29
i changed it... but it doesn't work
"numa" is just because i tried few times and that was the last one i tried...and I changed it just like you said
0
Tayyab Mubeen
31 October 2018, 19:30
check your spacing between characters...!!!
i write a comment copy from there and paste it...!!
0
Merima
31 October 2018, 19:33
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
String name = b.readLine();
int number = Integer.parseInt(b.readLine());
System.out.println(name + " will take over the world in " + number + " years. Mwa-ha-ha!");
}
}
0
Tayyab Mubeen
31 October 2018, 19:35
spaces...???
problem with spaces
0
Merima
31 October 2018, 19:41
i checked
*space* will....in *space*....*space* years...
i copied text from 'conditions'
0
Merima
31 October 2018, 19:52solution
I found out what's wrong
you just need to replace these 2 lines:
int number = Integer.parseInt(b.readLine());
String name = b.readLine();
+4