September 04, 2010, 01:51:21 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Java employee class  (Read 1155 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« on: July 19, 2008, 05:59:32 PM »

A small application I wrote for someone to calculate a salary.

Code
GeSHi (java):
  1. import java.util.InputMismatchException;
  2. import java.util.Scanner;
  3. public class Employee {
  4. static double hourlyRate = 0.0;
  5. static double hoursWorked = 0.0;
  6. public static void main(String[] args){
  7. Scanner sc = new Scanner(System.in);
  8. try{
  9. System.out.print("Employee name: ");
  10. String name  = sc.nextLine();
  11. System.out.print("Hourly rate $");
  12. hourlyRate = sc.nextDouble();
  13. System.out.print("Hour(s) worked: " );
  14. hoursWorked = sc.nextDouble();
  15. System.out.println("Employee " + name + " " + "with an hourly rate of $" + hourlyRate + " earned $" + getPay()
  16. + " by working " + hoursWorked + " hours a week.");
  17. }
  18. catch(InputMismatchException IMME){
  19. System.out.println("Input not correct!");
  20. }
  21. }
  22. public static double getPay(){
  23. double pay = hourlyRate * hoursWorked;
  24. return pay;
  25. }
  26. }
Created by GeSHI 1.0.7.20

Output:
Employee name: Micheal
Hourly rate $9,50
Hour(s) worked: 32
Employee Micheal with an hourly rate of $9.5 earned $304.0 by working 32.0 hours a week.

Additionally, check out my blogpost here: http://www.engineeringser...ecutive-and-hourlyworker/ for the pdf format and the other classes.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Javaforums.net :: a community about Java software development.
« on: July 19, 2008, 05:59:32 PM »

Your Ad Here
 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.23 seconds with 32 queries.

Google visited last this page August 29, 2010, 02:38:05 AM