on 03-16-2009 3:06 PM
Hi There,
New to the Java World and Im getting the following error when submitting this java program for compilation and output. Output is Via a html page
// just import the BufferedReader and inputstream reader
import java.io.BufferedReader;
import java.io.InputStreamReader;
class addtwonumbers
{
public static void main(String[] args)
{
// system.in reader (e.g. the input from the console)
InputStreamReader ISR = new InputStreamReader(System.in);
// buffer the console reader
BufferedReader BR = new BufferedReader(ISR);
// the default values for the two numbers
int val1 = 0;
int val2 = 0;
try
{
// output the question.
System.out.print("Enter two Numbers:\n");
// read in the console intput one line (BR.readLine) and then convert to a integer
val1 = Integer.parseInt(BR.readLine());
val2 = Integer.parseInt(BR.readLine());
}
catch (Exception ex)
{
//if the input was a string.
System.out.println(ex.toString());
}
// output the answer of adding both of the values together and * by 3
System.out.println("The result is " + (val1 + val2) * 3 );
}
}
The error message is "Error parsing output, please try again"
Thanks In advance.
Edited by: Conor O'Neill on Mar 16, 2009 4:11 PM
Hi,
Following is what you have to do to execute this program
Open command prompt
Enter the following command to compile
javac addtwonumbers.java
If the above line is executed successfully
use
java addtwonumbers
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Hi Ayyapparaj
>
> Thanks for getting back to me: yes I already have done what you suggested and it works fine, but I'm trying to output in an HTML page (in a table).
Hi,
What you mean by HTML page(in a table)?
Code what you have written above is a pure application that need to be run in the way i have mentioned above.
If you are interested to create a HTML page where you can enter two numbers and print their out put. You need to change the code altogether.
Regards
Ayyapparaj
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.