Error message when compiling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sabby0805
    New Member
    • Jun 2007
    • 3

    #1

    Error message when compiling

    Hi !
    New to the boards here. I am in wk 2 of a java programming class. We had to submit an assignment and this is what I did:
    // checkpoint 2.2: WeeklyPay1.java
    // Printing name of employee and weekly pay amount.
    import java.util.scann er; // program uses class scanner

    public class WeeklyPay1
    {
    // main method begins execution of Java application
    public static void main( String args[] );
    {
    // create Scanner to obtain input from command window
    Scanner input = new scanner( System.in );

    int name1; // Name Of Employee
    int numberhrs; // number of hours worked
    int hourlypay; // pay per hour
    int sum; // numberhrs * hourlypay

    System.out.prin t( " Enter Name Of Employee: " ); // prompt
    name1 = input.nextInt() ; // read first name from user

    System.out.prin t( " Enter Number Of Hours Worked: "); // prompt
    numberhrs = input.nextInt() ; // read number of hours worked from user

    System.out.prin t( " Enter Hourly Pay: " ); // prompt
    hourlypay = input.nextInt() ; // read hourly pay

    sum = numberhrs * hourlypay; // multiply numbers

    System.out.prin tf( "Sum is $d\n", Name employee ); // display employee name and weekly pay amount

    } // end method main

    } // end class WeeklyPay1

    and this is the error messsage I am getting:

    C:\Documents and Settings\Sabrin a\Desktop\Weekl yPay1.java:29: ')' expected
    System.out.prin tf( "Sum is $d\n", sum, employee name ); // display sum; name of employee
    ^
    1 error

    Tool completed with exit code 1

    Please help!
    thanks
    sabrina
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    #2
    Originally posted by sabby0805
    Hi !
    New to the boards here. I am in wk 2 of a java programming class. We had to submit an assignment and this is what I did:
    // checkpoint 2.2: WeeklyPay1.java
    // Printing name of employee and weekly pay amount.
    import java.util.scann er; // program uses class scanner

    public class WeeklyPay1
    {
    // main method begins execution of Java application
    public static void main( String args[] );
    {
    // create Scanner to obtain input from command window
    Scanner input = new scanner( System.in );

    int name1; // Name Of Employee
    int numberhrs; // number of hours worked
    int hourlypay; // pay per hour
    int sum; // numberhrs * hourlypay

    System.out.prin t( " Enter Name Of Employee: " ); // prompt
    name1 = input.nextInt() ; // read first name from user

    System.out.prin t( " Enter Number Of Hours Worked: "); // prompt
    numberhrs = input.nextInt() ; // read number of hours worked from user

    System.out.prin t( " Enter Hourly Pay: " ); // prompt
    hourlypay = input.nextInt() ; // read hourly pay

    sum = numberhrs * hourlypay; // multiply numbers

    System.out.prin tf( "Sum is $d\n", Name employee ); // display employee name and weekly pay amount

    } // end method main

    } // end class WeeklyPay1

    and this is the error messsage I am getting:

    C:\Documents and Settings\Sabrin a\Desktop\Weekl yPay1.java:29: ')' expected
    System.out.prin tf( "Sum is $d\n", sum, employee name ); // display sum; name of employee
    ^
    1 error

    Tool completed with exit code 1

    Please help!
    thanks
    sabrina
    First welcome to thescripts
    and please use the Wrap code tag. It's locate on top of the message box looks like this #

    you have several mistakes.
    1. look this line
    Scanner input = new scanner( System.in ); Something needs to be in upper cap.

    2 your main error lies here,
    System.out.prin tf( "Sum is $d\n", Name employee );
    What is Name employee doing? Don't you want to print the employee and hours, look at your objects that you have declared.


    nomad

    Comment

    • anubhav vij
      New Member
      • Jun 2007
      • 27

      #3
      the owner of this posting is there or not????
      u have made a lot of mistakes ,.....
      plz hold on while i clear it out....

      Comment

      • anubhav vij
        New Member
        • Jun 2007
        • 27

        #4
        This is the solution to your problem.....



        [CODE=java] import java.util.Scann er;

        public class WeeklyPay1 {
        // main method begins execution of Java application
        public static void main(String[] args) {
        // create Scanner to obtain input from command window
        Scanner input = new Scanner( System.in );

        String name1; // Name Of Employee
        int numberhrs; // number of hours worked
        int hourlypay; // pay per hour
        int sum=0; // numberhrs * hourlypay

        System.out.prin tln( " Enter Name Of Employee: " ); // prompt
        name1 = input.next(); // read first name from user

        System.out.prin tln( " Enter Number Of Hours Worked: "); // prompt
        numberhrs = input.nextInt() ; // read number of hours worked from user

        System.out.prin tln( " Enter Hourly Pay: " ); // prompt
        hourlypay = input.nextInt() ; // read hourly pay

        sum = numberhrs * hourlypay; // multiply numbers

        System.out.prin tln("sum is ::" +sum); // display employee name and weekly pay amount

        } // end method main

        } // end class WeeklyPay1
        [/CODE]

        Enjoy.....
        Last edited by r035198x; Jun 26 '07, 06:17 AM. Reason: added the missing code tags

        Comment

        • nomad
          Recognized Expert Contributor
          • Mar 2007
          • 664

          #5
          Originally posted by anubhav vij
          This is the solution to your problem.....



          [CODE=java] import java.util.Scann er;

          public class WeeklyPay1 {
          // main method begins execution of Java application
          public static void main(String[] args) {
          // create Scanner to obtain input from command window
          Scanner input = new Scanner( System.in );

          String name1; // Name Of Employee
          int numberhrs; // number of hours worked
          int hourlypay; // pay per hour
          int sum=0; // numberhrs * hourlypay

          System.out.prin tln( " Enter Name Of Employee: " ); // prompt
          name1 = input.next(); // read first name from user

          System.out.prin tln( " Enter Number Of Hours Worked: "); // prompt
          numberhrs = input.nextInt() ; // read number of hours worked from user

          System.out.prin tln( " Enter Hourly Pay: " ); // prompt
          hourlypay = input.nextInt() ; // read hourly pay

          sum = numberhrs * hourlypay; // multiply numbers

          System.out.prin tln("sum is ::" +sum); // display employee name and weekly pay amount

          } // end method main

          } // end class WeeklyPay1
          [/CODE]

          Enjoy.....
          You're not helping this person by solving their homework for them. Please try to give them clues or directions on what they are doing wrong.
          thanks
          nomad

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by nomad
            You're not helping this person by solving their homework for them. Please try to give them clues or directions on what they are doing wrong.
            thanks
            nomad
            I second that

            Comment

            • sabby0805
              New Member
              • Jun 2007
              • 3

              #7
              Wow,
              Thanks for the welcome and the responses. I appreciate the answer to my homework, as I can see I did it completly different. Is that why my program had an error? or would I have gotten the same results by using my program? I am trying to see if there is more then one way to write a program and get the same result or if it is a black and white issue. only one way to be right.
              thanks everyone for the help...this newbe needs all she can get!

              -Sabrina

              Comment

              • efultz
                New Member
                • Jun 2007
                • 5

                #8
                Originally posted by sabby0805
                Wow,
                Thanks for the welcome and the responses. I appreciate the answer to my homework, as I can see I did it completly different. Is that why my program had an error? or would I have gotten the same results by using my program? I am trying to see if there is more then one way to write a program and get the same result or if it is a black and white issue. only one way to be right.
                thanks everyone for the help...this newbe needs all she can get!

                -Sabrina
                Rarely, if ever, is there only one solution to a programming situation.

                Comment

                • sabby0805
                  New Member
                  • Jun 2007
                  • 3

                  #9
                  ok good to know! thanks!

                  Comment

                  Working...