hi everyone, i'm looking for some help please! i'm in an intro to java class and
i cant figure out what i'm doing wrong.i am getting an error message that says:

Ch3_PrExercise1.java:29: ';' expected
         String inData.;

like i said i just starting out so any help or advice is greatly appreciated!

import java.io.*;
import java.util.*;

public class Ch3_PrExercise1
{

     public static void main(String args[] );
     {
// declaration

     Scanner console = new Scanner(System.in); //read from keyboard
     int num1, num2;
     int num3, num4;
     String str;
     String inData.;
// input
     Scanner inFile = new Scanner(filereader("inData.txt"));     
         num1 = inData.nextint();
         num2 = inData.nextint();
         str = inData.next();
         num3 = inData.nextint();
         num4 = inData.nextint();
          inFile.close();


// process
     int sum = (num1 + num2); // add numbers from line 1
     int product = (num3 * num4); // multiply numbers from line 3


// output
     PrintWriter outFile = new PrintWriter("Outdata.dat");
     outFile.println( "The sum of (+ num1) and (+ num2) = + sum");
     outFile.println( "The character that comes after (+ str) in the unicode set is (+ <=)");
     outFile.println( "The product of (+ num3) and (+ num4) = + product");
     outFile.close();


     } // end main
} // end Ch3_PrExercise1

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Use code tags please.
Check line 15, there is a dot there. What for?
String inData.;

import java.io.*;
import java.util.*;

public class Ch3_PrExercise1
{

public static void main(String args[] );
{
// declaration

Scanner console = new Scanner(System.in); //read from keyboard
int num1, num2;
int num3, num4;
String str;
String inData.;
// input
Scanner inFile = new Scanner(filereader("inData.txt"));
num1 = inData.nextint();
num2 = inData.nextint();
str = inData.next();
num3 = inData.nextint();
num4 = inData.nextint();
inFile.close();


// process
int sum = (num1 + num2); // add numbers from line 1
int product = (num3 * num4); // multiply numbers from line 3


// output
PrintWriter outFile = new PrintWriter("Outdata.dat");
outFile.println( "The sum of (+ num1) and (+ num2) = + sum");
outFile.println( "The character that comes after (+ str) in the unicode set is (+ <=)");
outFile.println( "The product of (+ num3) and (+ num4) = + product");
outFile.close();


} // end main
} // end Ch3_PrExercise1

Edited 6 Years Ago by Stefano Mtangoo: n/a

you have given a ; after main that was wrong and your 17th line also contains errors it is written like this

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

and i hope the below code has solved your problem

import java.io.*;
import java.util.*;

class Ch3_PrExercise1
{

public static void main(String args[] )
{
// declaration

Scanner console = new Scanner(System.in); //read from keyboard
int num1, num2;
int num3, num4;
String str = "";
String inData = "";
// input
Scanner inFile = new Scanner(new FileReader("inData.txt"));
num1 = inData.nextint();
num2 = inData.nextint();
str = inData.next();
num3 = inData.nextint();
num4 = inData.nextint();
inFile.close();


// process
int sum = (num1 + num2); // add numbers from line 1
int product = (num3 * num4); // multiply numbers from line 3


// output
PrintWriter outFile = new PrintWriter("Outdata.dat");
outFile.println( "The sum of (+ num1) and (+ num2) = + sum");
outFile.println( "The character that comes after (+ str) in the unicode set is (+ <=)");
outFile.println( "The product of (+ num3) and (+ num4) = + product");
outFile.close();


} // end main
} // end Ch3_PrExercise

thanks for the help i really appreciate it! and next time i will use code tags sorry about that but now i know

This article has been dead for over six months. Start a new discussion instead.