Java help please

posted by .

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 :)

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Computer Science

    //program that puts two lists in order in one single list with all the numbers in order import java.util.Scanner; public class listOrder { public static void main (String [] args){ int [] list1; int [] list2; int [] list3; int temp; …
  2. Computers

    //program that puts two lists in order in one single list with all the numbers in order import java.util.Scanner; public class listOrder { public static void main (String [] args){ int [] list1; int [] list2; int [] list3; int temp; …
  3. Computer Science-Java

    Hi, I am writing an application class for a Lunar Calendar I created in a service class and I have to make sure it is able to detect that the year entered is not in the range of values(I have done this in the service class using a …
  4. programming

    Can anyone help me with this really confusing programming problem?
  5. Computer Science Computer Programming

    Please help! I cannot figure out what I am doing wrong. I cannot get the correct output when I run the system. Here is what I have entered in to Netbeans IDE: package shippingcharges; public class ShippingCharges { private double weight; …
  6. Java programming

    can you show me where is the wrong for this program..because it contains error..i don't know where is it wrong..help..tq.:) import java.util.Scanner; public class BMR { public static void main(String[] args, int x) { Scanner keyboard …
  7. Java programming- simulation of rolling dice

    This is what i have so far. I'm supposed to simulate the 4 dice tossed 1 million times . (so a total of 4 million) I'm trying to get the first die(If I can figure out the first one then I can figure out the other 3. So the trouble …
  8. Computer Science Principles

    I need to know what's wrong with my code and it's supposed to be in the Next-Line blocking style. import java.util.Scanner; public class AreaOfCircle{public static void main(String[] args) { double PI = 3.14159;double get_this; double …
  9. Java programming

    Okay so I am rewrite the program and it's still not coming right can anyone help me see what's going wrong here please I have to turn this in by tmw so here the program The following program is supposed to read two numbers from a file …
  10. Java programming

    Hi, I'm trying to figure out how to implement toString() methods into the JavaTest and H2ClassB classes so that the output would be 4 3 7 5 99 3: import java.util.ArrayList; public class JavaTest { ArrayList <JavaTest> list = …

More Similar Questions