Why doesn’t my solution pass testing? Here is my code:

public static void main(String[] args) throws Exception
{
//Add your code here

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String nm = reader.readLine();
String ag = reader.readLine();

System.out.print(nm+" will conquer the world in" + ag + " years. Bwahaha!");

}

Here is the output:

✓The program is compiled without errors. ✗The program runs correctly but it has not passed testing. Here is program output during runtime: Amigo will conquer the world in 5 years. Bwahaha!

My text matches with the one that is in the task. What is wrong?

asked 10 Feb '15, 07:45

Laga%20Bilaabo's gravatar image

Laga Bilaabo
2125
accept rate: 0%

edited 10 Feb '15, 08:56

Diego%20Carleone's gravatar image

Diego Carleone ♦♦
7615


12next »

Task description says to enter a number first, and then a name. Your code does the opposite. Please, always read description attentively, your code should do exactly as it is said in task description.

link

answered 10 Feb '15, 08:56

Diego%20Carleone's gravatar image

Diego Carleone ♦♦
7615
accept rate: 83%

i don't see where it states "enter a number first" :| ?

link

answered 20 Mar '15, 04:49

Gautam%20Roy's gravatar image

Gautam Roy
353
accept rate: 14%

Hey Robot! do what Diego tells you!!

link

answered 21 Mar '15, 19:15

Once%20the%20King%20of%20Andorra's gravatar image

Once the Kin...
676
accept rate: 11%

i have the same error and i have carefully read the description it says enter the <<name>> first then <<number>>

link

answered 17 Apr '15, 19:34

rahul's gravatar image

rahul
7916
accept rate: 15%

ublic static void main(String[] args) throws Exception { InputStream inputStream = System.in; Reader inputStreamReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

  /*BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));*/
  String name = bufferedReader.readLine();
  System.out.print(name);
  System.out.print(" will conquer the world in ");

  String sage = bufferedReader.readLine();
  int nage = Integer.parseInt(sage);
  System.out.print(sage);

  System.out.println(" years. Bwahaha!");
  /*String s1 = "will conquer the world in";
  String s2 = "years. Bwahaha!";
  System.out.println(name+" "+s1+" "+nage+" "+s2);*/

OUTPUT : Joe will conquer the world in 8 years. Bwahaha!

same as recommended !! I have tried everything...still not passing the test !!

Please suggest !! }

link

answered 30 Apr '15, 08:01

shariq15's gravatar image

shariq15
124
accept rate: 0%

edited 30 Apr '15, 08:03

the question written there is wrong . if you first take input number i.e age and than string i.e name you will pass the test but if you take string first and int later than you will fail in test.

link
This answer is marked "community wiki".

answered 13 May '15, 15:36

raswkp's gravatar image

raswkp
363
accept rate: 20%

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int i;     
i = Integer.parseInt(br.readLine());
String a = "will conquer the world in";
String b = br.readLine();
String c = "years. Bwahaha!";
System.out.print(b+" "+a+" "+i+" "+c);*/

input Joe 8

Although its a wrong program but it passed the test ... the written program is wrong !!

link

answered 14 May '15, 01:25

shariq15's gravatar image

shariq15
124
accept rate: 0%

" Task description says to enter a number first, and then a name. Your code does the opposite. Please, always read description attentively, your code should do exactly as it is said in task description. "

But task has next description:

"How to conquer the world Write a program that reads from keyboard a name and a number and displays the text: «name» will conquer the world in «number» years. Bwahaha! (The sequence of input data is important.)"

Please change description in task becouse it is wrong.

link

answered 09 Jun '15, 02:12

Igor%20Samigulin's gravatar image

Igor Samigulin
11
accept rate: 0%

The Task Description needs to be changed. It should read a number first and than a String. Below is my program that passed.

public class Solution { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String sAge = reader.readLine(); int nAge = Integer.parseInt(sAge); String name = reader.readLine(); System.out.print(name + " will conquer the world in " + nAge + " years. Bwahaha!"); } }

Input give: 3 XYZ

link

answered 10 Jun '15, 04:40

Suni's gravatar image

Suni
11
accept rate: 0%

edited 10 Jun '15, 04:41

Yeah, the description needs to be changed. Besides - you don't need to convert number in string ( int nAge = Integer.parseInt(sAge)), because you will display string in the end anyway. it works without this line.

link

answered 30 Jul '15, 10:39

baboong's gravatar image

baboong
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×51
×30
×11

Asked: 10 Feb '15, 07:45

Seen: 5,003 times

Last updated: 16 Mar, 11:44