hi: again i am feeling trouble from your compiler, here is my solution and its result. it says that it is compiled correctly but it has not passed testing. but when i run same code on eclipse on my system, it is working 100% perfect. so, please either make your compiler correct or make such question which don't give such faults. please...........

package com.javarush.test.level03.lesson08.task02;

/* Salary in 5 years
Write a program that reads from keyboard a name and two numbers. Program should display the text:
    «name» earns «number1» in «number2» years.

    Example:
    Nick earns $150,000 in 5 years.
*/

import java.io.*;

public class Solution

{

    public static void main(String[] args) throws Exception

    {

       BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

            String n,m,o;

            n= r.readLine();

            m= r.readLine();

            o= r.readLine();

           int  cm = Integer.parseInt(m);

           int co = Integer.parseInt(o);

           System.out.println(n + "earns "+ "$" + cm + " in " + co +" years.");
    }

    }

here is result from your compiler after my inputs:

✓ The program is compiled without errors.

✗ The program runs correctly but it has not pass testing.

This is program output during runtime:

sams earns $150000 in 5 years.

asked 11 Mar '15, 12:54

alimujtaba's gravatar image

alimujtaba
1115
accept rate: 0%

edited 13 Mar '15, 07:04

Elleonora%20Carry's gravatar image

Elleonora Carry ♦♦
275


12next »

Try program whithout line with Integet.parseint. And 19 line transform into:

System.out.println(n + " earns "+ "$" + m + " in " + o +" years.");
link

answered 11 Mar '15, 13:25

RabenokDmitry's gravatar image

RabenokDmitry
1263
accept rate: 14%

edited 13 Mar '15, 07:05

Elleonora%20Carry's gravatar image

Elleonora Carry ♦♦
275

1

i tried but i didn't work.

(14 Mar '15, 10:15) alimujtaba

remove parsing of 'm' variable

int  cm = Integer.parseInt(m);

it has number format with comma - 150,000

Integer.parseInt(m) throws an exception because it can parse only numbers without comma

(15 Mar '15, 06:37) Elleonora Carry ♦♦

Dont write m and o. Write with int cm = Integer.parseInt(r.readLine()); maybe.

link

answered 11 Mar '15, 13:39

Joseph's gravatar image

Joseph
213
accept rate: 0%

no... same result.

(14 Mar '15, 10:16) alimujtaba

Where is your "," cause the amount that should print is "150,000"

link

answered 19 Mar '15, 22:45

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

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

This is my code...m getting the answer exactly like the example provided..still no passing test...

package com.javarush.test.level03.lesson08.task02;

import java.io.*;

public class Solution
{
    public static void main(String[] args) throws Exception
    {
    BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

    String name = read.readLine();
    String sal = read.readLine();
    String yr = read.readLine();

    int number1 = Integer.parseInt(sal);
    int number2 = Integer.parseInt(yr);
    System.out.println(name +" earns $"+number1+",000 in "+number2+" years.");
    }
}

My Output :

✓ The program is compiled without errors.
✗ The program runs correctly but it has not pass testing.
This is program output during runtime:

Name earns $150,000 in 5 years.
link

answered 20 Mar '15, 05:03

Gautam%20Roy's gravatar image

Gautam Roy
3513
accept rate: 14%

don't use any commas or dollar signs and u're good to go :/

my code:

System.out.println(name+ " earns "+num1+" in "+num2+ " years.");
link

answered 07 Apr '15, 09:22

Gautam%20Roy's gravatar image

Gautam Roy
3513
accept rate: 14%

edited 07 Apr '15, 09:23

yeah the answer is working! without dollar sign "$" but why this sign is given in the question and the answer is not matching with it?? please correct it!

link

answered 17 Apr '15, 20:01

rahul's gravatar image

rahul
7916
accept rate: 15%

String name = br.readLine();
System.out.print(name);
System.out.print("earn");
String mn = br.readLine(); **/* do not use int for money coz it include $ sign*/**
System.out.print(mn);  
System.out.print("in");
int yr= Integer.parseInt(br.readLine());
System.out.print(yr);
System.out.print("years");
link

answered 11 May '15, 07:36

shariq15's gravatar image

shariq15
1215
accept rate: 0%

BufferedReader a=new BufferedReader(new InputStreamReader(System.in)); int b=Integer.parseInt(a.readLine()); int y=Integer.parseInt(a.readLine()); String h=a.readLine(); System.out.println(y+" earns "+b+" in "+y+" years."); what wrong with this code????

link

answered 26 Jul '15, 18:42

zeramal's gravatar image

zeramal
1
accept rate: 0%

Please JavaRush either correct your solution or don't give such questions.Your wrong solutions irritates a lot.

link

answered 27 Jul '15, 10:19

ascender's gravatar image

ascender
1
accept rate: 0%

it's works and pass the test Input data:

Nick

150000

5

import java.io.*;

public class Solution

{

public static void main(String[] args) throws Exception

{
    //add your code here

    InputStream inputStream = System.in;
    Reader inputStreamReader = new InputStreamReader(inputStream);
    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
    String name = bufferedReader.readLine();
    String number1 = bufferedReader.readLine();
    //int number_a = Integer.parseInt(number1);
    String number2 = bufferedReader.readLine();
    int number_2 = Integer.parseInt(number2);
    String string =name + " earns "+ number1+ " in "+ number_2 +" years.";
    System.out.println(string);

}

}

link

answered 19 Mar, 11:35

maestroukr's gravatar image

maestroukr
111
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:

×1

Asked: 11 Mar '15, 12:54

Seen: 3,045 times

Last updated: 01 Sep, 17:03

Related questions