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

Recommended Answers

All 4 Replies

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

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

No problem, mark the thread solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.