Employee payroll program problems
I have done good so far but now im stuck and lost on how to take my program to the next step, kids got sick and i missed like a week of school so im behind. I am suppose to modify the Payroll Program so that it uses a class to store and retrieve the employee?s name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. I am lost on the bold part..
here is what I have:
//Calculates weekly pay for an employee
import java.util.Scanner; // program uses class Scanner
public class BeemansPayroll
private double rate;
private double hours;
private String name;
//Used to save info
public BeemansPayroll(String Name, double PayRate, double Hours)
String name = Name;
double rate = PayRate;
double hours = Hours;
private static void Quit()
System.out.println("Thank You for using Beeman's Payroll");
System.exit(0);
// 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 name = "";
do {
System.out.print("Enter Employee Name or stop to quit: ");
// prompt for name
name = input.next(); // get name
if (name.equals("stop"))
System.out.println("Thank You for using Beeman's Payroll");
Quit();
} //end if
else
double PayRate;
double Hours;
double Pay;
System.out.print("Please enter Employee payrate:$ "); // prompt
PayRate = input.nextDouble(); // read first number from user
while (PayRate <= 0)
System.out.println ("Invalid amount, Payrate must be positive");
System.out.print("Please enter valid payrate:$ ");
PayRate = input.nextDouble();
} //end if
System.out.print("Please enter Employee hours: "); // prompt
Hours = input.nextDouble(); // read second number from user
while (Hours <= 0)
System.out.println ("Invalid amount, Hours must be positive");
System.out.print("Please enter hours worked: ");
Hours = input.nextDouble();
} //end if
Pay = PayRate * Hours; // multiply numbers
System.out.printf("Employee Pay for the week %s, is $%.2f\n", name,
(PayRate * Hours)); // display product
} //end else
}while (!name.equals("stop"));
Quit();
} // end method main
} // end class Beeman's Payroll
john774077 wrote:
Like I said, I am lost, with all that is going on I have done the reading 4 times , Then try reading a different source such as the Sun Java tutorials. They are excellent and there is no substitute to your reading and learning. We can help you debug an error in your code, but we are not a tutorial service nor a homework production service. Note also that we are all volunteers.
on top of kids getting sick and taking three algebra all at once. I advice you to not go on and on about this. This is not our problem and won't affect how or if someone helps you. If anything continued mention of this will turn many away who would otherwise help you.
How or where do I go about breaking it down?You are redeclaring the variables in your constructor, i.e.,:
String name = Name; // don't do thisDon't do this because you'll never change the class's name variable this way. Instead in the constructor do something like this for each variable:
name = Name;or
this.name = Name;Later you will need to read up on Java naming conventions.
As for creating the method, you should read up on method creation in your text book or tutorial. That'll give you a better explanation than we can, I think.
Similar Messages
-
Hello I need help with the following code for a Payroll program.
//CheckPoint: Payroll Program Part 3
//Java Programming IT215
//Arianne Gallegos
//05/02/2007
//Payroll3.java
//Payroll program that calculates the weekly pay for an employee.
import java.util.Scanner; // program uses class Scanner
public class Payroll3
private string name;
private double rate;
private double hours;
// Constructor to store Employee Data
public EmployeeData( String nameOfEmployee, double hourlyRate, double hoursWorked )
name = nameOfEmployee;
rate = hourlyRate;
hours = hoursWorked;
} // end constructor
} //end class EmployeeData
// main method begins execution of java application
public static void main( String args[] )
System.out.println( "Welcome to the Payroll Program! " );
boolean quit = false; // This flag will control whether we exit the loop below
// Loop until user types "quit" as the employee name:
while (!quit)
// create scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
System.out.println(); // outputs a blank line
System.out.print( "Please enter the employee name or quit to terminate program: " );
// prompt for and input employee name
String nameOfEmployee = input.nextLine(); // read what user has inputted
if ( nameOfEmployee.equals("quit")) // Check whether user indicated to quit program
System.out.println( "Program has ended" );
quit = true;
else
// User did not indicate to stop, so continue reading info for this iteration:
float hourlyRate; // first number to multiply
float hoursWorked; // second number to multiply
float product; // product of hourlyRate and hoursWorked
System.out.print( "Enter hourly rate: " ); // prompt
hourlyRate = input.nextFloat(); // read first number from user
while (hourlyRate <= 0) // prompt until a positive value is entered
System.out.print( "Hourly rate must be a positive value. " +
"Please enter the hourly rate again: " ); // prompt for positive value for hourly rate
hourlyRate = input.nextFloat(); // read first number again
System.out.print( "Enter hours worked: " ); // prompt
hoursWorked = input.nextFloat(); // read second number from user
while (hoursWorked <= 0) // prompt until a positive value is entered
System.out.print( "Hours worked must be a positive value. " +
"Please enter the hours worked again: " ); // prompt for positive value for hours worked
hoursWorked = input.nextFloat(); // read second number again
product = (float) hourlyRate * hoursWorked; // multiply the hourly rate by the hours worked
// Display output for this iteration
System.out.println(); // outputs a blank line
System.out.print( nameOfEmployee ); // display employee name
System.out.printf( "'s weekly pay is: $%,.2f\n", product); // display product
System.out.println(); // outputs a blank line
// Display ending message:
System.out.println( "Thank you for using the Payroll program!" );
System.out.println(); // outputs a blank line
} // end method main
} // end class Payroll3I am getting the following errors:
Payroll3.java:18: invalid method declaration; return type required
public EmployeeData( String nameOfEmployee, double hourlyRate, double hours
Worked )
^
Payroll3.java:28: class, interface, or enum expected
public static void main( String args[] )
^
Payroll3.java:33: class, interface, or enum expected
boolean quit = false; // This flag will control whether we exit the loop b
elow
^
Payroll3.java:36: class, interface, or enum expected
while (!quit)
^
Payroll3.java:42: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:43: class, interface, or enum expected
System.out.print( "Please enter the employee name or quit to terminate p
rogram: " );
^
Payroll3.java:45: class, interface, or enum expected
String nameOfEmployee = input.nextLine(); // read what user has inputted
^
Payroll3.java:48: class, interface, or enum expected
if ( nameOfEmployee.equals("quit")) // Check whether user indicated to q
uit program
^
Payroll3.java:51: class, interface, or enum expected
quit = true;
^
Payroll3.java:52: class, interface, or enum expected
^
Payroll3.java:57: class, interface, or enum expected
float hoursWorked; // second number to multiply
^
Payroll3.java:58: class, interface, or enum expected
float product; // product of hourlyRate and hoursWorked
^
Payroll3.java:60: class, interface, or enum expected
System.out.print( "Enter hourly rate: " ); // prompt
^
Payroll3.java:61: class, interface, or enum expected
hourlyRate = input.nextFloat(); // read first number from user
^
Payroll3.java:64: class, interface, or enum expected
while (hourlyRate <= 0) // prompt until a positive value is entered
^
Payroll3.java:68: class, interface, or enum expected
hourlyRate = input.nextFloat(); // read first number again
^
Payroll3.java:69: class, interface, or enum expected
^
Payroll3.java:72: class, interface, or enum expected
hoursWorked = input.nextFloat(); // read second number from user
^
Payroll3.java:75: class, interface, or enum expected
while (hoursWorked <= 0) // prompt until a positive value is entered
^
Payroll3.java:79: class, interface, or enum expected
hoursWorked = input.nextFloat(); // read second number again
^
Payroll3.java:80: class, interface, or enum expected
^
Payroll3.java:86: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:87: class, interface, or enum expected
System.out.print( nameOfEmployee ); // display employee name
^
Payroll3.java:88: class, interface, or enum expected
System.out.printf( "'s weekly pay is: $%,.2f\n", product); // display
product
^
Payroll3.java:89: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:91: class, interface, or enum expected
^
Payroll3.java:96: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:98: class, interface, or enum expected
} // end method main
^
The problem I am having is getting the constructor to work with the rest of the program can someone please point out to me how to correct this. I have read my textbook as well as tutorials but I just don't seem to get it right. Please help.
P.S. I have never taken a programming class before so please be kind.Ok, I changed the name of the constructor:
//CheckPoint: Payroll Program Part 3
//Java Programming IT215
//Arianne Gallegos
//04/23/2007
//Payroll3.java
//Payroll program that calculates the weekly pay for an employee.
import java.util.Scanner; // program uses class Scanner
public class Payroll3
private string name;
private float rate;
private float hours;
// Constructor to store Employee Data
public void Payroll3( string nameOfEmployee, float hourlyRate, float hoursWorked )
name = nameOfEmployee;
rate = hourlyRate;
hours = hoursWorked;
} // end constructor
} //end class EmployeeData
// main method begins execution of java application
public static void main( String args[] )
System.out.println( "Welcome to the Payroll Program! " );
boolean quit = false; // This flag will control whether we exit the loop below
// Loop until user types "quit" as the employee name:
while (!quit)
// create scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
System.out.println(); // outputs a blank line
System.out.print( "Please enter the employee name or quit to terminate program: " );
// prompt for and input employee name
String nameOfEmployee = input.nextLine(); // read what user has inputted
if ( nameOfEmployee.equals("quit")) // Check whether user indicated to quit program
System.out.println( "Program has ended" );
quit = true;
else
// User did not indicate to stop, so continue reading info for this iteration:
float hourlyRate; // first number to multiply
float hoursWorked; // second number to multiply
float product; // product of hourlyRate and hoursWorked
System.out.print( "Enter hourly rate: " ); // prompt
hourlyRate = input.nextFloat(); // read first number from user
while (hourlyRate <= 0) // prompt until a positive value is entered
System.out.print( "Hourly rate must be a positive value. " +
"Please enter the hourly rate again: " ); // prompt for positive value for hourly rate
hourlyRate = input.nextFloat(); // read first number again
System.out.print( "Enter hours worked: " ); // prompt
hoursWorked = input.nextFloat(); // read second number from user
while (hoursWorked <= 0) // prompt until a positive value is entered
System.out.print( "Hours worked must be a positive value. " +
"Please enter the hours worked again: " ); // prompt for positive value for hours worked
hoursWorked = input.nextFloat(); // read second number again
product = (float) hourlyRate * hoursWorked; // multiply the hourly rate by the hours worked
// Display output for this iteration
System.out.println(); // outputs a blank line
System.out.print( nameOfEmployee ); // display employee name
System.out.printf( "'s weekly pay is: $%,.2f\n", product); // display product
System.out.println(); // outputs a blank line
// Display ending message:
System.out.println( "Thank you for using the Payroll program!" );
System.out.println(); // outputs a blank line
} // end method main
} // end class Payroll3I still get the following error codes:
C:\IT215\Payroll3>javac Payroll3.java
Payroll3.java:28: class, interface, or enum expected
public static void main( String args[] )
^
Payroll3.java:33: class, interface, or enum expected
boolean quit = false; // This flag will control whether we exit the loop b
elow
^
Payroll3.java:36: class, interface, or enum expected
while (!quit)
^
Payroll3.java:42: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:43: class, interface, or enum expected
System.out.print( "Please enter the employee name or quit to terminate p
rogram: " );
^
Payroll3.java:45: class, interface, or enum expected
String nameOfEmployee = input.nextLine(); // read what user has inputted
^
Payroll3.java:48: class, interface, or enum expected
if ( nameOfEmployee.equals("quit")) // Check whether user indicated to q
uit program
^
Payroll3.java:51: class, interface, or enum expected
quit = true;
^
Payroll3.java:52: class, interface, or enum expected
^
Payroll3.java:57: class, interface, or enum expected
float hoursWorked; // second number to multiply
^
Payroll3.java:58: class, interface, or enum expected
float product; // product of hourlyRate and hoursWorked
^
Payroll3.java:60: class, interface, or enum expected
System.out.print( "Enter hourly rate: " ); // prompt
^
Payroll3.java:61: class, interface, or enum expected
hourlyRate = input.nextFloat(); // read first number from user
^
Payroll3.java:64: class, interface, or enum expected
while (hourlyRate <= 0) // prompt until a positive value is entered
^
Payroll3.java:68: class, interface, or enum expected
hourlyRate = input.nextFloat(); // read first number again
^
Payroll3.java:69: class, interface, or enum expected
^
Payroll3.java:72: class, interface, or enum expected
hoursWorked = input.nextFloat(); // read second number from user
^
Payroll3.java:75: class, interface, or enum expected
while (hoursWorked <= 0) // prompt until a positive value is entered
^
Payroll3.java:79: class, interface, or enum expected
hoursWorked = input.nextFloat(); // read second number again
^
Payroll3.java:80: class, interface, or enum expected
^
Payroll3.java:86: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:87: class, interface, or enum expected
System.out.print( nameOfEmployee ); // display employee name
^
Payroll3.java:88: class, interface, or enum expected
System.out.printf( "'s weekly pay is: $%,.2f\n", product); // display
product
^
Payroll3.java:89: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:91: class, interface, or enum expected
^
Payroll3.java:96: class, interface, or enum expected
System.out.println(); // outputs a blank line
^
Payroll3.java:98: class, interface, or enum expected
} // end method main
^
27 errors
Any other suggestions? -
Payroll Program Part 3 (confused)
Okay, I'm sure you guys are sick of me by now. :-)
This is the last part of an assignment that's supposed to calculate an employee's weekly pay, these are the requirements for this phase:
Payroll Program Part 3:
Modify the Payroll Program so that it uses a class to store and retrieve the employee's
name, the hourly rate, and the number of hours worked. Use a constructor to initialize the
employee information, and a method within that class to calculate the weekly pay. Once
stop is entered as the employee name, the application should terminate.
So I wrote the separate class:
// Employee class stores and retrieves employee information
import java.util.Scanner; // program uses class scanner
public class Employee1
// instance fields
private double rate;
private double hours;
private String employeeName;
// class constructor
public Employee1()
rate = 0.0;
hours = 0.0;
employeeName = "";
} // end class Employee1 constructor
// set rate
public void setrate(double rate)
rate = rate;
} // end method setrate
// get rate
public double getrate()
return rate;
} // end method getrate
// set hours
public void sethours(double hours)
hours = hours;
} // end method sethours
// get hours
public double gethours()
return hours;
} // end method gethours
// set employee name
public void setemployeeName(String employeeName)
employeeName = employeeName;
} // end method setemployeeName
// get employee name
public String getemployeeName()
return employeeName;
} // end method getemployeeName
// calculate and return weekly pay
public double calculateWeeklyPay()
return rate * hours; // display multiplied value of rate and hours
} // end method calculateWeeklyPay
} // end class Employee1...and modified the original program:
// Payroll Program Part 3
// Employee1 object used in an application
import java.util.Scanner; // program uses class Scanner
public class Payroll3
// main method begins execution of Java application
public static void main( String args[] )
// create and initialize an Employee1 object
Employee1 employee = new Employee1(); // invokes Employee1 constructor
employee.setrate();
employee.sethours();
Double weeklyPay = employee.calculateWeeklyPay();
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
String employeeName = ""; // employee name to display
Double rate; // first number to multiply
Double hours; // second number to multiply
Double weeklyPay; // product of rate and hours
// loop until 'stop' read from user
while( employeeName.equals("stop") )
System.out.print( "Enter employee name or 'stop' to quit: "); // prompt
employeeName = input.next (); // read employee name from user
System.out.print( "Enter hourly rate: " ); // prompt
rate = input.nextDouble(); // read first number from user
// check if hourly rate is positive number
if( rate <= 0 )
System.out.print( "Enter a positive amount" );
System.out.print( "Enter hourly rate: " ); // prompt
rate = input.nextDouble(); // read first number from user
} // end if
System.out.print( "Enter hours worked: " ); // prompt
hours = input.nextDouble(); // read second number from user
// check if hours worked is positive number
if( hours <= 0 )
System.out.print( "Enter a positive amount" );
System.out.print( "Enter hours worked: " ); // prompt
hours = input.nextDouble(); // read second number from user
} // end if
weeklyPay = rate * hours; // multiply numbers
System.out.printf( "Employee \n", employeeName); // display employee name
System.out.printf( "Weekly pay is $%d\n", weeklyPay ); // display weekly pay
} // end while
} // end method main
} // end class Payroll3I managed to compile the separate class just fine, but when I tried to compile Payroll3 I got these [three error messages|http://img150.imageshack.us/img150/3919/commandpromptrl9.jpg].
I think I have an idea of what I did wrong, but I'm not sure what to change. I tried to emulate the code from some examples in my chapters and online but I'm a little in the dark about how these to files are actually supposed to work together.
Also, the requirements say the program should end when 'stop' is entered as the employee name, I don't know if that applies to what I already have in Payroll3 or if I should use a sentinel controlled loop again in Employee1. I tried that and I got a whole host of error messages (probably did it wrong) so I just removed it.
I'm going to play around with this a little more, I'm reluctant to change anything in my separate class since I managed to compile it, so I'm going to try some different things with Payroll3.
If anyone has any suggestions I would greatly appreciate it, I'm a total newbie here so don't hesitate to state the obvious, it might not be so obvious to me (sorry for the lengthy post).
Edited by: Melchior727 on Apr 22, 2008 11:21 AM
Edited by: Melchior727 on Apr 22, 2008 11:23 AMemployee.setrate();
employee.sethours();First of all, your Employee1 class' setrate() and sethours() method both requires a parameter of type double.
// loop until 'stop' read from user
while( employeeName.equals("stop") )
System.out.print( "Enter employee name or 'stop' to quit: "); // prompt
employeeName = input.next (); // read employee name from userIf you want the while loop to stop when "stop" is entered, then change the condition to:
while (!(employeeName.equals("stop))){code}
This way the loop will perform whatever you tell it to do when it's NOT "stop".
Also, take the prompt statements and paste them once outside the while loop, and a second time at the end of the loop:
<example>
== prompt for reply
== while()
== {
== ....
== prompt again
== }
<example>
Fix those problems first and see how it goes -
I have a Java assignment due this Sunday, and I'm lost. I'm completely new to Java and this is only the second thing I've tried so far, so bear with me please, and don't laugh. :)
This is the assignment:
+"Create a non-GUI based Java application that calculates weekly pay for an+
+employee. The application should display 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 should then print out the name of the employee and the weekly pay+
+amount. In the printout, display the dollar symbol ($) to the left of the weekly pay+
+amount and format the weekly pay amount to display currency."+
In my chapter it talks about how to write a program that adds integers, so I tried to emulate that example but instead make it multiply. I wasn't sure how to do the employee's name, there is an explanation on printing lines of text, but not inputing and displaying text, only numbers. So for the employee's name I did some guesswork (for the data type declaration, etc), so I have no idea if that's right, (or if any of this is for that matter). I also don't know how to make it display the dollar symbol.
Here is what I did so far:
// Payroll Program Part 1
import java.util.Scanner; // program uses class Scanner
public class Multiplication
// 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 name; // employee name to display
int number1; // first number to multiply
int number2; // second number to multiply
int product; // product of number1 and number2
System.out.print( "Enter employee name: "); // prompt
name = input.nextString (); // read employee name from user
System.out.print( "Enter hourly rate: " ); // prompt
number1 = input.nextInt(); // read first number from user
System.out.print( "Enter hours worked: " ); // prompt
number2 = input.nextInt(); // read second number from user
product = number1 * number2; // multiply numbers
System.out.println( "Employee \n", name): // display employee name
System.out.printf( "Weekly pay is %d\n", product ); // display product
} // end method main
} // end class MultiplicationKnow that I'm not asking anyone to do my homework for me, I just need some direction. I don't know what I'm doing, my teacher isn't helping and I'm not getting anything out of my chapters. Any assistance would be appreciated.newark wrote:
You don't know how to print the $ symbol? Your code shows that you know how to print with System.out.println()...all that's left is finding the $ symbol on the keyboard...
So what exactly is your problem? You say you don't know if your code is right. I have a suggestion...*run* your code and see if it works. If it works, it's right. If not, then come back here and let us know what it does do, including any exact error messages you might get.It's not easy to detect sarcasm over the Internet. Seriously I didn't think it would be that simple, but I just added the symbol, so now it says +"Weekly pay is $%d\n"+
I don't know if that's in there right.
Also, I tried to compile the program, and it found four errors, I fixed a couple (changed : to ; and apparently the public class name has to be the same as the file name, so now its public class Payroll1), but there are two others mistakes I made, both of which were my attempt at trying to include the program request the input and display the output for the employee name.
They are both "cannot find symbol" errors, the first one is input.*nextString ()*; and the second is System.out.*println*
So my guess at replacing int with "String" was wrong, and println is wrong. I'm going to try something else. -
I need to install version 22. This is under the guidance of my payroll provider. The program will not work until version 27 comes out. I do not need help solving the problem with the payroll program, I just want to install version 22 of Firefox.
Firefox 27.0 is in Beta at moment until February 4 release.
You would be better off trying to use wither the User Agent Switcher extension or ua-site-switch extension to try a fool this one site or to use the portable Firefox 22.0 just for this one site.
https://addons.mozilla.org/en-US/firefox/addon/user-agent-switcher/
https://addons.mozilla.org/en-US/firefox/addon/ua-site-switch/
You should not switch to using 22.0 only due to known potential vulnerabilities that is fixed in newer versions like the current Fx 26.0.
The Portable Firefox is a self contained program as it will not interfere with your current Firefox 26.0 install. It can even be used completely on a usb flash drive. http://sourceforge.net/projects/portableapps/files/Mozilla%20Firefox%2C%20Portable%20Ed./Mozilla%20Firefox%2C%20Portable%20Edition%2022.0/ and pick your language.
I posted a ink to portable Firefox 22.0 as their homepage currently only links to the current 26.0 and 24.2.0esr on http://portableapps.com/apps/internet/firefox_portable -
I have a question. I have to write a payroll program that calculates and prints the monthly paycheck for an employee with 6 deductions coming out, fed and state tax, social, medicare/aid, pension and health.
I need to structure it so it prompts the user to enter their gross pay amount and employee name, output stored in a file and output formatted to 2 places. I've tried finding other programs that would be similar to this so that I can use it as a guide to writing this one that I need to complete but I have not been able to find anything that gives me some solid help. Does anybody have a program I could look at to use as a guide for writing this or links that would show me how to proceed on structuring this. I'm lost at the moment and this is my last hope. Thanks for the guidance.import java.util.Scanner;
import javax.swing.JOptionPane;
public class payrollapplication /**
* @param args the command line arguments
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);//declare and initialize variables
String employeeName;
Double federalTax;
Double stateTax;
Double socialTax;
Double medicareMedicaid;
Double pension;
Double deductions;
Double netPay;
int healthInsurance;
int grossAmount;
int netAmount;
String inputStr;
String outputStr;
federalTax = .15;
stateTax = .035;
socialTax = .0575;
medicareMedicaid = .0275;
pension = .05;
healthInsurance = 75;//input employee name
employeeName = JOptionPane.showInputDialog("Enter Employee Name:"); //input gross amount
inputStr = JOptionPane.showInputDialog("Enter Gross Amount:");
grossAmount = Integer.parseInt(inputStr);//figure Federal tax amount
federalTax = federalTax * grossAmount;//figure State tax amount
stateTax = stateTax * grossAmount;//figure Social security tax
socialTax = socialTax * grossAmount;//figure Medicare/Medicaid tax
medicareMedicaid = medicareMedicaid * grossAmount;//figure Pension amount
pension = pension * grossAmount;//figure total deduction for Net amount
deductions = pension + medicareMedicaid + socialTax + stateTax + federalTax;//figure Net pay
netPay = deductions - grossAmount;//Configure data for the output string
outputStr = "Employee Name: " + employeeName + "/n"
+ "Gross Amount: $"
+ String.format("%.2f", grossAmount)+ "/n"
+ "Federal Tax: $"
+ String.format("%.2f", federalTax)+ "/n"
+ "State Tax: $"
+ String.format("%.2f", stateTax)+ "/n"
+ "Social Security Tax: $"
+ String.format("%.2f", socialTax)+ "/n"
+ "Medicare/Medicaid Tax: $"
+ String.format("%.2f", medicareMedicaid)+ "/n"
+ "Pension Plan: $"
+ String.format("%.2f", pension)+ "/n"
+ "Health Insurance: $"
+ String.format("%.2f", healthInsurance)+ "/n"
+ "Net Pay: $"
+ String.format("%.2f", netPay);
JOptionPane.showMessageDialog(null, outputStr, "Payroll Breakdown", JOptionPane.INFORMATION_MESSAGE);I am getting an error when I run this application. It says this: Exception in thread "main" java.util.IllegalFormatConversionException: f != java.lang.Integer
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:3992)
at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2721)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2666)
at java.util.Formatter.format(Formatter.java:2432)
at java.util.Formatter.format(Formatter.java:2366)
at java.lang.String.format(String.java:2770)
at payrollapplication.main(payrollapplication.java:76)
Java Result: 1
BUILD SUCCESSFUL (total time: 10 seconds)
Thanks again.
Edited by: Nightryno on Oct 10, 2008 8:35 PM
Edited by: Nightryno on Oct 10, 2008 9:00 PM -
I need help with my payroll program which is for my Java class. The assignment is: Modify the payroll program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within the class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate.
With the program that I have below, I'm getting <indentier> expected
weeklyPay.calculatePay( rate, hours );
Help is needed as soon as possible because it is due today.
import java.util.Scanner;
public class Payroll3
Employee weeklyPay = new Employee();
weeklyPay.calculatePay( rate, hours );
class Employee
double rate;
double hours;
double pay;
private String employeeName;
public Employee( String name )
employeeName = name;
public void setEmployeeName( String name )
employeeName = name;
public String getEmployeeName()
return employeeName;
public static double calculatePay( double rate, double hours )
Scanner input = new Scanner( System.in );
System.out.print( "Enter employee name or stop to quit: " );
employeeName = input.nextLine();
while ( !employeeName.equals("stop") )
System.out.printf( "Enter %s's hourly rate: ", employeeName );
rate = input.nextDouble();
System.out.printf( "Enter %s's number of hours worked: ", employeeName );
hours = input.nextDouble();
pay = rate*hours;
System.out.printf( "%s's payment for the week is $%.2f\n", employeeName, pay );
System.out.println();
System.out.print( "Enter employee name or stop to quit: " );
employeeName = input.next();
System.out.println();
}weeklyPay.calculatePay( rate, hours );What are rate and hours?
Before you answer, no they are not available in your Payroll3 class becuase you declared them in the Employee class. -
Hi all,
I was looking for this java programming problem which had to do with a large building and there was some gallons of water involved in it too somehow and we had to figure out the height of the buiding using java. This problem is also in one of the java books and I really need to find out all details about this problem and the solution. NEED HELP!!
Thanks
macYes, it will. The water will drain from the bottom of
the tank until the pressure from the water inside the
tank equals the pressure from the pipe. In other
words, without a pump, the water will drain out until
there is the same amount of water in the tank as in
the pipe The water pressure depends on the depth of the water, not the volume. So once the depth of the water inside the pipe reaches the same depth as the water inside the tank it will stop flowing. This will never be above the height of the tank.
I found this applet which demonstrates our problem. If you run it you can drag the guy up to the top, when water in his hose reaches the level of the water in the tank it will stop flowing out. -
How to write hr payroll programe can any body help me please
<THREAD LOCKED. Please read the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] to discover why>
Edited by: Mike Pokraka on Aug 12, 2008 2:57 PMHi,
go through the following Blog..
The specified item was not found.
Check this -
looping payroll results using pnpce ldb
Regards.
Eshwar. -
Subject:
programming problem
Date:
Sun, 10 Mar 2002 19:48:34 +0800
From:
LibraryPublicStation <[email protected]>
Organization:
Hong Kong University of Science and Technology
Newsgroups:
hkust.cs.class.201
Hi, I have some problems on the following code:
The code has no compiling error. but
Why I can't get the RGB value of my image since I can get the width and
height of the image.
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.Graphics.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;
import java.awt.color.*;
import com.sun.image.codec.jpeg.*;
import java.awt.geom.*;
public class Sun
public static void main(String args[])
double[][] database_graph=new double[0][900];
// put the image in a row with 900 column
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image1 = new ImageIcon("imges.jpg").getImage();//load the image to
image1
BufferedImage buffer;//Buffer the image to get the RGB value
buffer = new BufferedImage(image1.getWidth(null),image1.getHeight(null),
BufferedImage.TYPE_INT_ARGB);
ColorModel a=buffer.getColorModel();
System.out.println(a);
for(int j=0;j<buffer.getWidth();j++)
for(int k=0;k<buffer.getHeight();k++)
int rgb=buffer.getRGB(j,k);//get the red,green,blue value of the graph
int red = ((rgb&0xff0000)>>16);
int green = ((rgb&0xff00)>>8);
int blue = rgb&0xff;
database_graph[0][buffer.getHeight()*j+k] = (red + green + blue)/3;
System.out.println(database_graph[0][buffer.getHeight()*j+k]+" "+red+"
"+green+" "+blue);
} // change back to gray scaleTry this :
ImageIcon icon = new ImageIcon("imges.jpg");
Image image1 = icon.getImage();
BufferedImage buffer = new BufferedImage(icon.getIconWidth(),icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
...But I think, in your problem, you want to get the image in a BuffererdImage ?
ImageIcon icon = new ImageIcon("imges.jpg");
BufferedImage buffer= (BufferedImage)icon.getImage();
...Denis -
Management of global employee payroll configuration in sap hr
Dear Expert,
Kindly give me light on management of global employees payroll configuration.I have gone through different thread in sdn which are related to this but not able to find out accurate path to do this.
Regards,
SankarsanThanks Wrens and Sreenu,
It works and changes the status of MGE to activate... but this still does not release the infotypes (700 series for GE ie 702, 703, 706, 715 etc with others). This is the situation after activating switches CCURE MAINS and CCURE GLEMP.
The message displayed is:
"You attempted to access infotype &1. According to the system settings, however, it is not permitted to use this infotype."
Any clues on this restriction.
Regards. -
Balancing BW Employee payroll to R3
Hi,
I'm looking for the best method to balance employee payroll (0PY_C02) between BW and R3. We are using end-date of the in-period to allocate pay to month. I'm trying to use the Wage Types report but it isn't evident how to select so as to get comparable data. Is there a better method?For the record, this is possible using the Wage type report : Transaction PC00_M99_CWTR ou PGM H99CWTR0.
You must make sure you use the in- or for-view, depending upon the option you take when assigning payroll data to calendar month (i.e. based in end date of in-period or for-period, etc) -
Coldfusion server problem or programming problem?
Hello experts,
I have been experiencing problems when accessing this website using Mac (and Parallels/WinXP).
http://tinyurl.com/3yh3d8l
Because there is no problem when using Windows PC, the programmer suggested that it might be a CF server problem, but one of my IT said it's programming issue (basically he said the web programmer is wrong). I have very limited access to PC at work but I need the data from that website. I'd like to give input to the webprogrammer but I don't know what to say. Could you please give me some suggestions? Thank you.hi Adam,
Just tested in Mac, the site works in FireFox. But Safari won't load it at all. Progress bar keep spinning but screen doesn't change.
So is this something to do with the programming problem or Safari is being picky? I can use FireFox during presentation but I'd like the option to be able to use Safari (iPad?). -
dear sirs, i work with forms 6i
i have programming problem and i want to solve it
the problem is
i have table contain the following fields
AREA_CODE NOT NULL NUMBER(8)
AREA_NAME NOT NULL VARCHAR2(30)
EAREA_NAME VARCHAR2(30)
UP_AREA_CODE NUMBER(8)
AREA_TYPE NUMBER(1)
AREA_LEVEL NUMBER(15)
transfer_fees number(15,3)
i want to get the value of transfer_fees, depend on the area code which i want, but if transfer_fees is null i should get the other transfer_fees of the up_area_code as the up level of area code, and if also null then get the value of transfer_fees of the up level of area code and so on.
please help me urgently
YasserHi yasser
it's not precise for me , It needs a lot of details but according to the existing information
Now we have 3 options
Option1 : Get the transfer_fees according to AREA_CODE -- i don't know how not clear for me
Option 2 : IF transfer_fees IS NULL then get it's value from up_area_code (then i am assuming that up_area_code has a value currently during the user input so all we have is to think that we can get it's value from a simple assign statement in WHEN-VALIDATE-ITEM trigger of transfer_fees item as ...
IF :transfer_fees IS NULL THEN
:transfer_fees :=:up_area_code;
END IF;and so on...
Hope this helps...
Regards,
Amatu Allah -
I'm new to Ubuntu & Linuz OS. I've started to see a pop-up window that says: System Program Problem Detected- Do you want to report the problem. When I click yes, I'm asked to enter my password to access problem reports of system programs. Should I be asked for my password ???
I am fairly new to Ubuntu, but that does not sound unexpected. Ubuntu tends to have everyone use a limited account that needs to ask for a password before carrying out operations like installing software.
Maybe you are looking for
-
I bought the two disc DVD today, and the second DVD is also a digital copy of the movie. I redeemed it through iTunes, but when it started to download I kept getting err = -43. I closed iTunes and reopened it, but now the movie is not even in my pend
-
Plotting two graphs in one single graph
Hi. This is my first time using control and simulation. I want to plot two graphs within a single graph. It seems that I have to use bundle and build arrays functions but I just do not know how to plot them. The x points and y points of (2) are j
-
Canvas on web page without javascript
Can anybody tell me that how i can construct canvas on web page without using javascript. Please guide me for the process i should follow Edited by: 864869 on Jun 10, 2011 8:49 AM
-
IOS 5 has introduced new Podcast bug, resuming playback
I use the standard Apple earphones to listen to podcasts, and I almost always trigger playback by pressing the button on the earphones which resumes playback of whatever you were last playing, for me normally the last podcast. This used to work fine
-
Hi I am trying to compare Prior Year vs Current year revenues for a particular period. My input parameter is Fiscal period. I have created two Restricted key figures. First one is Revenue key figure restricted by Fiscal period. (User input period) Se