[code=java]import java.io.*;
import java.awt.*;
import hsa.Console;
public class Calculator
{
static Console c;
public static void main (String [] args) throws IOException
{
c = new Console ();
int num1, num2;
int difference, sum, product, quotant;
String awnser;
DataInputStream keyboard = new DataInputStream (System.in);
System.out.prin tln ("Calculator Ready: enter a value");
num1 = keyboard.readIn t ();
System.out.prin tln ("Enter another value: ");
num2 = keyboard.readIn t ();
System.out.prin tln ("What would you like to do with there two values?");
System.out.prin tln ("add, subtract, multiply or divide?");
awnser = keyboard.readLi ne ();
difference = num1 - num2;
sum = num1 + num2;
product = num1 * num2;
quotant = num1 / num2;
if (awnser.equals ("subtract") )
{
System.out.prin tln (num1 + " - " + num2 + " = " + difference);
}
else if (awnser.equals ("multiply") )
{
System.out.prin tln (num1 + " x " + num2 + " = " + product);
}
else if (awnser.equals ("divide"))
{
System.out.prin tln (num1 + " / " + num2 + " = " + quotant);
}
else
{
System.out.prin tln (num1 + " + " + num2 + " = " + sum);
}
[/code] This is a calculator simulation its not the whole thing but i just wanted to fix the error i am having before i move on. The language is java and the type of programs i am using are basic ones their ready anf Drjava.
The error message is:
import java.awt.*;
import hsa.Console;
public class Calculator
{
static Console c;
public static void main (String [] args) throws IOException
{
c = new Console ();
int num1, num2;
int difference, sum, product, quotant;
String awnser;
DataInputStream keyboard = new DataInputStream (System.in);
System.out.prin tln ("Calculator Ready: enter a value");
num1 = keyboard.readIn t ();
System.out.prin tln ("Enter another value: ");
num2 = keyboard.readIn t ();
System.out.prin tln ("What would you like to do with there two values?");
System.out.prin tln ("add, subtract, multiply or divide?");
awnser = keyboard.readLi ne ();
difference = num1 - num2;
sum = num1 + num2;
product = num1 * num2;
quotant = num1 / num2;
if (awnser.equals ("subtract") )
{
System.out.prin tln (num1 + " - " + num2 + " = " + difference);
}
else if (awnser.equals ("multiply") )
{
System.out.prin tln (num1 + " x " + num2 + " = " + product);
}
else if (awnser.equals ("divide"))
{
System.out.prin tln (num1 + " / " + num2 + " = " + quotant);
}
else
{
System.out.prin tln (num1 + " + " + num2 + " = " + sum);
}
[/code] This is a calculator simulation its not the whole thing but i just wanted to fix the error i am having before i move on. The language is java and the type of programs i am using are basic ones their ready anf Drjava.
The error message is:
Code:
java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:363)
at Calculator.main(Calculator.java:25)
Comment