I am a student taking a java class online. its kinda hard because I don't have anyone to talk to directly.
I do not want someone to do this for me i just want a simple yes or no answer.
I have created a program for my second assignment.
The application displays text that requests the user input the name of the employee, the hourly rate, and the number of hours worked for that week. The application then prints out the name of the employee and the weekly pay amount.
my code for this application is as follows :
import java.util.Scanner; // program uses class Scanner
public class PayrollApp
{
// main method begins execution of java application
public static void main(String args[])
{
// create a scanner to obtain input in command window
Scanner input = new Scanner( System.in );
String employeename; // Name of employee
double hourlyrate; // Amount made in one hour
double hoursworked; // Number of hours worked in one week
double weeklypay; // The multiple of hourly rate and hours worked in one week
System.out.println("Enter an employee name:"); //prompt
employeename = input.nextLine();
// display employee name and weekly pay
System.out.printf( "Weekly Pay for %s,is $%.2f\n", employeename, weeklypay);
} // end method main
} // end class
End code:
I am currently using netbeans and the line that says "public class PayrollApp" gives me an error that says i have to define the class PayrollApp in another file.
My question is this. do i need to define it in another file. and if so what do i include?
(i am sorry, being new to this i may not be asking the question correctly)
I am currently using netbeans and the line that says "public class PayrollApp" gives me an error that says i have to define the class PayrollApp in another file.
My question is this. do i need to define it in another file. and if so what do i include?
(i am sorry, being new to this i may not be asking the question correctly)
I have no idea why Netbeans do this as your code is fine and will run on any other IDE without problems. You can try and remove public before class PayrollApp. If this doesn't help, please post exact error which you get from Netbeans
Yes. You need another file for it to work. I tried it in Netbeans and I couldn't get the figure out how to add the file so I used another Jgrasp and it automatically added the file and the program was successful. Here's the link to where you can get Jgrasp. http://spider.eng.auburn.edu/user-cgi/grasp/grasp.pl?;dl=download_jgrasp.html
Removing 'public' allows the program to run in Netbeans. I don't quite understand why it doesn't allow you to use it. Oh well.
Last edited by Mr. Bill Klepto; Sep 21st, 2007 at 4:14 am. Reason: Read the post above mine after I finished finding Jgrasp for the link.
yah... for your reference in future, in java you have to give the same name with java extension as the class name (unlike C++)... if you want to run it manually, add JRE in your classpath then simply open a console and compile it using:
c:/>yourAppDir/ javac PayrollApp.java
This will create PayrollApp.class file, run it using:
java PayrollApp
At the beginning using console will help you better understanding the process.
Thanks Loads everyone.. i thought i was going insane :-?
yep xfered to a file that is Named Payrollone.java.. for some reason i was trying to do something like modules.
i only have ever encountered psudeocode before so java class is a little rough.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.