Error?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tukewl4u

    #1

    Error?

    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\C onExec.exe "C:\Program
    Files\Java\jdk1 .5.0_07\bin\jav ac.exe" "GradeBookTest. java"
    GradeBookTest.j ava:30: ')' expected
    gradebook2.setC ourseName ( String Name ); // set the course name
    ^
    1 error
    Execution finished.

    From the following:

    import java.util.Scann er;


    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.prin tf( "GradeBook for course name is: %s\n",
    gradebook1.getC ourseName() );

    System.out.prin tf( "This course is presented by: %s\n",
    gradebook2.getC ourseName() );


    // prompt for and read course name
    System.out.prin tln( "Please enter the course name:" );
    String Name = input.nextLine( ); // read a line of text
    gradebook2.setC ourseName ( String Name ); // set the course name
    System.out.prin tln(); // outputs a blank line

    // display welcome message after specifying course name
    GradeBook.displ ayMessage();





    } //end main
    } // end class GradeBookTest



  • A. W. Dunstan

    #2
    Re: Error?

    Drop the "String" - you want "Name", not "String Name". A cut & paste
    error, maybe?
    gradebook2.setC ourseName ( String Name ); // set the course name
    Tukewl4u wrote:
    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\C onExec.exe "C:\Program
    >Files\Java\jdk 1.5.0_07\bin\ja vac.exe" "GradeBookTest. java"
    >
    GradeBookTest.j ava:30: ')' expected
    gradebook2.setC ourseName ( String Name ); // set the course name
    ^
    1 error
    >Execution finished.
    >
    >
    From the following:
    >
    import java.util.Scann er;
    >
    >
    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.prin tf( "GradeBook for course name is: %s\n",
    gradebook1.getC ourseName() );
    >
    System.out.prin tf( "This course is presented by: %s\n",
    gradebook2.getC ourseName() );
    >
    >
    // prompt for and read course name
    System.out.prin tln( "Please enter the course name:" );
    String Name = input.nextLine( ); // read a line of text
    gradebook2.setC ourseName ( String Name ); // set the course name
    System.out.prin tln(); // outputs a blank line
    >
    // display welcome message after specifying course name
    GradeBook.displ ayMessage();
    >
    >
    >
    >
    >
    } //end main
    } // end class GradeBookTest
    --
    Al Dunstan, Software Engineer
    OptiMetrics, Inc.
    3115 Professional Drive
    Ann Arbor, MI 48104-5131

    Comment

    • Vaxius

      #3
      Re: Error?

      On Mon, 25 Sep 2006 10:23:26 -0400, A. W. Dunstan wrote:
      Drop the "String" - you want "Name", not "String Name". A cut & paste
      error, maybe?
      ....
      > String Name = input.nextLine( ); // read a line of text
      > gradebook2.setC ourseName ( 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.

      Comment

      Working...