Can some one tell me why I'm getting this error? I really don't understand
why it shouldn't work.
> Executing: C:\Program Files\ConTEXT\ConExec.exe "C:\Program
> Files\Java\jdk1.5.0_07\bin\javac.exe" "GradeBookTest.java"
GradeBookTest.java:30: ')' expected
gradebook2.setCourseName ( String Name ); // set the course name
^
1 error
> Execution finished.
From the following:
import java.util.Scanner;
public class GradeBookTest
{
// main method begins program execution
public static void main ( String args[] )
{
// create GradeBook object
GradeBook gradebook1 = new GradeBook( "CSCI 3134 Introduction to Java
Programming" );
GradeBook gradebook2 = new GradeBook( "Joe Schmo" );
// display initial value of courseName for each GradeBook
System.out.printf( "GradeBook for course name is: %s\n",
gradebook1.getCourseName() );
System.out.printf( "This course is presented by: %s\n",
gradebook2.getCourseName() );
// prompt for and read course name
System.out.println( "Please enter the course name:" );
String Name = input.nextLine(); // read a line of text
gradebook2.setCourseName ( String Name ); // set the course name
System.out.println(); // outputs a blank line
// display welcome message after specifying course name
GradeBook.displayMessage();
} //end main
} // end class GradeBookTest
A. W. Dunstan - 25 Sep 2006 15:23 GMT
Drop the "String" - you want "Name", not "String Name". A cut & paste
error, maybe?
> gradebook2.setCourseName ( String Name ); // set the course name
> Can some one tell me why I'm getting this error? I really don't understand
> why it shouldn't work.
[quoted text clipped - 42 lines]
> } //end main
> } // end class GradeBookTest

Signature
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI 48104-5131
Vaxius - 09 Oct 2006 06:23 GMT
> Drop the "String" - you want "Name", not "String Name". A cut & paste
> error, maybe?
...
>> String Name = input.nextLine(); // read a line of text
>> gradebook2.setCourseName ( String Name ); // set the course name
...
In addition, I would recommend that you not capitalize the first letter of
variables, as it can sometimes get confusing.