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/it says "Be sure that you haven't mixed up the order of r...
Harika Yantrapragada
Level 7
Hyderabad
  • 31.10.2018
  • 1715views
  • 22comments

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?

Question about the task Plan to conquer the world
Java Syntax,  Level 3,  Lesson 8
Resolved

Enter the number and name from the keyboard. Display the following string:
<name> will take over the world in <number> years. Mwa-ha-ha!

Here's an example:
Kevin will take over the world in 8 years. Mwa-ha-ha!

The order in which the data is input matters a lot.

Requirements:
  • The program should output text.
  • The program must read data from the keyboard.
  • The displayed text must contain the entered name.
  • The displayed text must contain the entered number.
  • The displayed text must fully match the task conditions.
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!"); } }
0
Comments (22)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Tayyab Mubeen
Level 16 , Lahore, Pakistan
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
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
modify your line number 15...!!!! hope this help...!!!
0
Harika Yantrapragada
Level 7 , Hyderabad, India
31 October 2018, 19:03
even these modifications gives same output. It shows that there is an error in input order
0
Harika Yantrapragada
Level 7 , Hyderabad, India
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
Level 7 , Hyderabad, India
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
Level 16 , Lahore, Pakistan
31 October 2018, 19:12
the compiler is showing error because you used inputStreamReader but you need this InputStreamReader
0
Tayyab Mubeen
Level 16 , Lahore, Pakistan
31 October 2018, 19:14
mark it resolved...!!!
0
Harika Yantrapragada
Level 7 , Hyderabad, India
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
Level 16 , Lahore, Pakistan
31 October 2018, 19:15
change the variable names... you should use name and number
0
Harika Yantrapragada
Level 7 , Hyderabad, India
31 October 2018, 19:19
even that's giving the same error
0
Tayyab Mubeen
Level 16 , Lahore, Pakistan
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
int number = Integer.parseInt(b.readLine());
0
Merima
Level 5 , Kacuni, Bosnia and Herzegovina
31 October 2018, 19:23
still not working ...
0
Harika Yantrapragada
Level 7 , Hyderabad, India
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
Level 16 , Lahore, Pakistan
31 October 2018, 19:24
also check your spaces...!!! you got wrong out put merima...!!!
0
Tayyab Mubeen
Level 16 , Lahore, Pakistan
31 October 2018, 19:26
System.out.println(name+" will take over the world in " +number+" years. Mwa-ha-ha!");
0
Tayyab Mubeen
Level 16 , Lahore, Pakistan
31 October 2018, 19:27
show code
0
Harika Yantrapragada
Level 7 , Hyderabad, India
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
Level 5 , Kacuni, Bosnia and Herzegovina
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
Level 16 , Lahore, Pakistan
31 October 2018, 19:30
check your spacing between characters...!!! i write a comment copy from there and paste it...!!
0
Merima
Level 5 , Kacuni, Bosnia and Herzegovina
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
Level 16 , Lahore, Pakistan
31 October 2018, 19:35
spaces...??? problem with spaces
0
Merima
Level 5 , Kacuni, Bosnia and Herzegovina
31 October 2018, 19:41
i checked *space* will....in *space*....*space* years... i copied text from 'conditions'
0
Merima
Level 5 , Kacuni, Bosnia and Herzegovina
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
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