5 Replies - 569 Views - Last Post: 19 May 2009 - 05:15 PM Rate Topic: -----

#1 alimac  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-May 09

Can not compile

Post icon  Posted 19 May 2009 - 09:06 AM

I can not figure out where my mistake is!

// Payroll.java
import java.util.Scanner; //

public class Payroll2

{//

   public void Payroll2(String employeename, double hourlywage, double hoursworked)
   {//

	   String name = employeeName;
	   double wage = hourlyWage;
	   double hours = hoursWorked;

   }//

   //main method begins execution of Java application
   
   {

	  //
	  System.out.println("Welcome to Program Payroll.");//
 
	  
	  // Loop until "Stop" is entred as employee Name:

	  while (true) { //
	   
	  System.out.print("Enter employee name: \n or stop end program" );

	  String Name = input.nextLine(); //

	  if (employeename = "Stop"); //

	  double hourlywage = input.nextLine(); //
	  double hoursworked = input.nextLine(); //				  
	  double sum = input.nextLine; //

	  System.out.println("Enter hourly wage:"); //

		hourlywage = input.nextDouble(); // 

	   while (hourlyWage <= 0){// Loop until a positive number is enetered
   
	  System.out.println("Hourly wage must be a positive number.");//
	   
	  } //

	  System.out.println("Enter hours worked:"); //
  
		hoursworked = input.nextdoubkle(); //

	   while (hoursworked <= 0){// Loop until a positive number is enetered

	  System.out.println("Hours worked must be a positive number.");//
	
	  } //

	  sum = hourlywage * hoursworked; //
	 
	  System.out.println("Weekly pay for " + Name + " is $" + String.valueOf(sum));
	  
	  
	  System.out.print("Enter employee name: \n or stop end program" );
	  
	  }// Loop
	  
	   
	   
	 }// end while
	   
 
   }// end main 

}// end class Payroll2

This post has been edited by alimac: 19 May 2009 - 11:50 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Can not compile

#2 phil1000  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 176
  • Joined: 26-February 09

Re: Can not compile

Posted 19 May 2009 - 09:44 AM

can you close your code with the [ /code ] you missed a slash.

But your problem is that you don't have this
public static void main(String[] args)


and from your comments, it should go here: //main method begins execution of Java application

This post has been edited by phil1000: 19 May 2009 - 09:46 AM

Was This Post Helpful? 0
  • +
  • -

#3 bigtonyk  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 61
  • Joined: 17-May 09

Re: Can not compile

Posted 19 May 2009 - 01:35 PM

View Postalimac, on 19 May, 2009 - 08:06 AM, said:

I can not figure out where my mistake is!

   public void Payroll2(String employeename, double hourlywage, double hoursworked)
   {//

	   String name = employeeName;
	   double wage = hourlyWage;
	   double hours = hoursWorked;

   }//





Your parameter names don't match the names in the usage. Java is case sensitive.

employeename is not the same variable as employeeName.
Was This Post Helpful? 0
  • +
  • -

#4 alimac  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-May 09

Re: Can not compile

Posted 19 May 2009 - 04:20 PM

Ok I have done what you have both suggested and still can not compile. I get error code - :java 73: class, interface or enum expected. Could anyone recommend a book that would be of help to me? This is my first java class.

here is my revised code

// Payroll2.java
import java.util.Scanner; //

public class Payroll2

{//

   public void Payroll2(String employeeName, double hourlyWage, double hoursWorked)
   {//

	   String name = employeeName;
	   double wage = hourlyWage;
	   double hours = hoursWorked;

   }//

   public static void main(String[] args)

   {//main method begins execution of Java application
   
   
	  System.out.println("Welcome to Program Payroll.");//
 
	  
	  // Loop until "Stop" is enetred as employee Name:

	  while (true) { //
	   
	  System.out.print("Enter employee name: \n or stop end program" );

	  String Name = input.nextLine(); //

	  
	  double hourlywage = input.nextLine(); //
	  double hoursworked = input.nextLine(); //				  
	  double sum = input.nextLine; //

	  System.out.println("Enter hourly wage:"); //

		hourlywage = input.nextDouble(); // 

	   if (hourlywage <= 0){// Loop until a positive number is enetered
   
	  System.out.println("Hourly wage must be a positive number.");//
	   
	  } //

	  System.out.println("Enter hours worked:"); //
  
		hoursWorked = input.nextdoubkle(); //

	   if (hoursworked <= 0){// Loop until a positive number is entered

	  System.out.println("Hours worked must be a positive number.");//
	
	  } //

	  sum = hourlyWage * hoursWorked; //
	 
	  System.out.println("Weekly pay for " + Name + " is $" + String.valueOf(sum));
	  
	  
	  System.out.print("Enter employee name: \n or stop end program" );
	  
		 }// Loop
	  
	   
	  }// end while
	   
 
   }// end main 

}// end class Payroll2

Was This Post Helpful? 0
  • +
  • -

#5 jcmaster2  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 183
  • Joined: 27-April 09

Re: Can not compile

Posted 19 May 2009 - 04:21 PM

You mean you do not allready have a textbook for this Java class you are taking...what kind of class is it...
Was This Post Helpful? 0
  • +
  • -

#6 alimac  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-May 09

Re: Can not compile

Posted 19 May 2009 - 05:15 PM

It is an online course and my reading is all online, it would be easier to have a book I could open in front of me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1