# Need some help

• January 6th, 2010, 07:04 PM
BusyLiving10
Need some help
Hello, I'm new to the forums but thought this would be the best place to check. I'm taking a Java course in High School and we have programming projects that we take home to do. I had it all done but my computer was shut off and it didn't save. I also wasn't at school today to ask my teacher for help so I just wrote everything the best I could from memory. Here is the code I need help with. Its a drive class for a main class which is mean't to add, subtract, multiply, and divide two fractions that are supplied by the user.

Quote:

import java.util.Scanner;

public class RationalDriver
{
public static void main(String [] args)
{
Scanner scan = new Scanner;
int num1;
int num2;
int den1;
int den2;

System.out.println("Please enter the numerator of the first fraction: ");
num1 = scan.nextInt();
System.out.println("Please enter the denominator of the first fraction: ");
den1 = scan.nextInt();
System.out.println("Please enter the numerator of the second fraction: ");
num2 = scan.nextInt();
System.out.println("Please enter the denominator of the second fraction: ");
den2 = scan.nextInt();

Rational rat1 = new Rational (num1 , den1);
Rational rat2 = new Rational (num2 , den2);

Rational ratSub = rat1.subtract(rat2);
Rational ratMultiply = rat1.multiply(rat2);
Rational ratDivide = rat1.divide(rat2);

System.out.println("When your two fractions are subtracted, they equal: "ratSub);
System.out.println("When your two fractions are multiplied, they equal: "ratMultiply);
System.out.println("When your two fractions are divided, they equal: "ratDivided);

}
}
The problem I am having is when I try to compile this code, the "Scanner scan = new Scanner;" is highlighted and I'm told that " '(' or '[' is expected." The thing is I don't know where I would be missing that at. Also if there any other problems you can see, please tell me as well.
• January 6th, 2010, 07:28 PM
copeg
Re: Need some help
See the API for Scanner (Java 2 Platform SE 5.0) (HINT: the first few paragraphs should address your problem)
• January 7th, 2010, 04:41 AM
Exoskeletor
Re: Need some help