Monday
April 21, 2014

Homework Help: Java help please

Posted by Mike on Sunday, March 2, 2008 at 2:20am.

I am trying to run the following program and am getting this error:

java.util.InputMismatchException

import java.io.*;

import java.util.*;

public class Pre2

{

static Scanner console = new Scanner(System.in);


public static void main(String[] args)throws IOException
{

Scanner inFile = new Scanner(new FileReader("Pre2Input.txt"));

PrintWriter outFile = new

PrintWriter(new FileWriter("Pre2Output.txt"));

int num1, num2;

num1 = inFile.nextInt();

num2 = inFile.nextInt();

outFile.println("Sum = " + (num1 + num2));

outFile.close();

}

}


What am I doing wrong? Pls help. Thanks in advanced :)

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

Computer Science-Java - Hi, I am writing an application class for a Lunar ...
Java programming - can you show me where is the wrong for this program..because ...
Computer Science Computer Programming - Please help! I cannot figure out what I ...
Java - I am trying to write an algorithm for my JAVA class and am having some ...
programming - Can anyone help me with this really confusing programming problem...
java - Write a java application that finds the smallest of several integers. ...
Computer Science - Consider the following application files: /JavaCS1/src/...
Java programming- simulation of rolling dice - This is what i have so far. I'm ...
JAVA PROGRAMMING - "POWERS" Compute the power of a number given the base and ...
Java Panel Problem - I am supose to draw a grid and center it with a 10 pix ...

Search
Members