SlideShare a Scribd company logo
1 of 4
Download to read offline
/**
* The java Payroll that prompts user to enter
* hourly rate of pay and number of hours worked.
* Then calculates the gross pay and net pay
* and print to console.
* */
//Payroll.java
import java.util.Scanner;
public class Payroll
{
public static void main(String[] args)
{
//declare variables for hourly rate and hours worked
double hourlyRate;
int hoursWorked;
//Set tax rate as 0.15 (15 percent )
final double WITH_HOLD_TAX=0.15;
//Set grossPay=0
double grossPay=0;
//Set tax =0
double tax=0;
//Set netPay=0
double netPay=0;
//Create an instance of Scanner class
Scanner inputScanner =new Scanner(System.in);
System.out.println("Enter hourly rate of pay");
//prompt for hourly rate
hourlyRate=Integer.parseInt(inputScanner.nextLine());
System.out.println("Enter number of hours worked");
//prompt for number of hours
hoursWorked=Integer.parseInt(inputScanner.nextLine());
//Calculate grossPay
//multiply hoursWorked by hourlyRate
grossPay=hoursWorked*hourlyRate;
//calculate with hold tax
tax=grossPay*WITH_HOLD_TAX;
//calculate netPay
//subtract tax from grossPay
netPay=grossPay-tax;
//print gross pay and net pay to console
System.out.println("Gross Pay : "+grossPay);
System.out.println("Net pay : "+netPay);
}
}
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Sample output:
Enter hourly rate of pay
10
Enter number of hours worked
50
Gross Pay : 500.0
Net pay : 425.0
Solution
/**
* The java Payroll that prompts user to enter
* hourly rate of pay and number of hours worked.
* Then calculates the gross pay and net pay
* and print to console.
* */
//Payroll.java
import java.util.Scanner;
public class Payroll
{
public static void main(String[] args)
{
//declare variables for hourly rate and hours worked
double hourlyRate;
int hoursWorked;
//Set tax rate as 0.15 (15 percent )
final double WITH_HOLD_TAX=0.15;
//Set grossPay=0
double grossPay=0;
//Set tax =0
double tax=0;
//Set netPay=0
double netPay=0;
//Create an instance of Scanner class
Scanner inputScanner =new Scanner(System.in);
System.out.println("Enter hourly rate of pay");
//prompt for hourly rate
hourlyRate=Integer.parseInt(inputScanner.nextLine());
System.out.println("Enter number of hours worked");
//prompt for number of hours
hoursWorked=Integer.parseInt(inputScanner.nextLine());
//Calculate grossPay
//multiply hoursWorked by hourlyRate
grossPay=hoursWorked*hourlyRate;
//calculate with hold tax
tax=grossPay*WITH_HOLD_TAX;
//calculate netPay
//subtract tax from grossPay
netPay=grossPay-tax;
//print gross pay and net pay to console
System.out.println("Gross Pay : "+grossPay);
System.out.println("Net pay : "+netPay);
}
}
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Sample output:
Enter hourly rate of pay
10
Enter number of hours worked
50
Gross Pay : 500.0
Net pay : 425.0

More Related Content

Similar to The java Payroll that prompts user to enter hourly rate .pdf

Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxWrite a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxlez31palka
 
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdfP1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdfaquacareser
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answersQuratulain Naqvi
 
I want a java program that can convert a number of base 10 into its .pdf
I want a java program that can convert a number of base 10 into its .pdfI want a java program that can convert a number of base 10 into its .pdf
I want a java program that can convert a number of base 10 into its .pdffashiongallery1
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfadianantsolutions
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfKUNALHARCHANDANI1
 
Easy practice with current timemillis method
Easy practice with current timemillis methodEasy practice with current timemillis method
Easy practice with current timemillis methodNooria Esmaelzade
 
The java program MortgagePayment that prompts user to .pdf
   The java program MortgagePayment that prompts  user to .pdf   The java program MortgagePayment that prompts  user to .pdf
The java program MortgagePayment that prompts user to .pdfannamalaiagencies
 
C++ project
C++ projectC++ project
C++ projectSonu S S
 

Similar to The java Payroll that prompts user to enter hourly rate .pdf (10)

07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxWrite a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
 
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdfP1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
P1.javaimport java.util.Scanner;keyboard inputting package pub.pdf
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
I want a java program that can convert a number of base 10 into its .pdf
I want a java program that can convert a number of base 10 into its .pdfI want a java program that can convert a number of base 10 into its .pdf
I want a java program that can convert a number of base 10 into its .pdf
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
 
Easy practice with current timemillis method
Easy practice with current timemillis methodEasy practice with current timemillis method
Easy practice with current timemillis method
 
The java program MortgagePayment that prompts user to .pdf
   The java program MortgagePayment that prompts  user to .pdf   The java program MortgagePayment that prompts  user to .pdf
The java program MortgagePayment that prompts user to .pdf
 
C++ project
C++ projectC++ project
C++ project
 

More from angelfashions02

N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
N= sp3 F = p orbital of F overlap with sp3 hybrid.pdfangelfashions02
 
I think you are missing an S species in the first.pdf
                     I think you are missing an S species in the first.pdf                     I think you are missing an S species in the first.pdf
I think you are missing an S species in the first.pdfangelfashions02
 
H2te , H2 Se, H2S , H2O .pdf
                     H2te , H2 Se, H2S , H2O                          .pdf                     H2te , H2 Se, H2S , H2O                          .pdf
H2te , H2 Se, H2S , H2O .pdfangelfashions02
 
Compound II and III only. .pdf
                     Compound II and III only.                        .pdf                     Compound II and III only.                        .pdf
Compound II and III only. .pdfangelfashions02
 
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdfUntil 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdfangelfashions02
 
The Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdfThe Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdfangelfashions02
 
sickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdfsickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdfangelfashions02
 
I think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdfI think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdfangelfashions02
 
ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf
ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdfConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf
ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdfangelfashions02
 
Before Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdfBefore Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdfangelfashions02
 
Answer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdfAnswer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdfangelfashions02
 
AnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdfAnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdfangelfashions02
 
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdfAnswer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdfangelfashions02
 
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdfa)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdfangelfashions02
 
A database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdfA database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdfangelfashions02
 
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdfangelfashions02
 

More from angelfashions02 (20)

Phenol S.pdf
                     Phenol                                      S.pdf                     Phenol                                      S.pdf
Phenol S.pdf
 
N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
 
isotopes .pdf
                     isotopes                                      .pdf                     isotopes                                      .pdf
isotopes .pdf
 
I think you are missing an S species in the first.pdf
                     I think you are missing an S species in the first.pdf                     I think you are missing an S species in the first.pdf
I think you are missing an S species in the first.pdf
 
H2te , H2 Se, H2S , H2O .pdf
                     H2te , H2 Se, H2S , H2O                          .pdf                     H2te , H2 Se, H2S , H2O                          .pdf
H2te , H2 Se, H2S , H2O .pdf
 
E=1 Solu.pdf
                     E=1                                      Solu.pdf                     E=1                                      Solu.pdf
E=1 Solu.pdf
 
Compound II and III only. .pdf
                     Compound II and III only.                        .pdf                     Compound II and III only.                        .pdf
Compound II and III only. .pdf
 
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdfUntil 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdf
 
The Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdfThe Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdf
 
sickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdfsickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdf
 
I think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdfI think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdf
 
ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf
ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdfConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf
ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf
 
Before Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdfBefore Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdf
 
Answer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdfAnswer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdf
 
AnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdfAnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdf
 
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdfAnswer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdf
 
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdfa)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
 
A database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdfA database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdf
 
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
 
x= 38Solutionx= 38.pdf
x= 38Solutionx= 38.pdfx= 38Solutionx= 38.pdf
x= 38Solutionx= 38.pdf
 

Recently uploaded

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscapingDr. M. Kumaresan Hort.
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 

Recently uploaded (20)

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 

The java Payroll that prompts user to enter hourly rate .pdf

  • 1. /** * The java Payroll that prompts user to enter * hourly rate of pay and number of hours worked. * Then calculates the gross pay and net pay * and print to console. * */ //Payroll.java import java.util.Scanner; public class Payroll { public static void main(String[] args) { //declare variables for hourly rate and hours worked double hourlyRate; int hoursWorked; //Set tax rate as 0.15 (15 percent ) final double WITH_HOLD_TAX=0.15; //Set grossPay=0 double grossPay=0; //Set tax =0 double tax=0; //Set netPay=0 double netPay=0; //Create an instance of Scanner class Scanner inputScanner =new Scanner(System.in); System.out.println("Enter hourly rate of pay"); //prompt for hourly rate hourlyRate=Integer.parseInt(inputScanner.nextLine()); System.out.println("Enter number of hours worked"); //prompt for number of hours
  • 2. hoursWorked=Integer.parseInt(inputScanner.nextLine()); //Calculate grossPay //multiply hoursWorked by hourlyRate grossPay=hoursWorked*hourlyRate; //calculate with hold tax tax=grossPay*WITH_HOLD_TAX; //calculate netPay //subtract tax from grossPay netPay=grossPay-tax; //print gross pay and net pay to console System.out.println("Gross Pay : "+grossPay); System.out.println("Net pay : "+netPay); } } --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- Sample output: Enter hourly rate of pay 10 Enter number of hours worked 50 Gross Pay : 500.0 Net pay : 425.0 Solution /** * The java Payroll that prompts user to enter * hourly rate of pay and number of hours worked. * Then calculates the gross pay and net pay * and print to console. * */
  • 3. //Payroll.java import java.util.Scanner; public class Payroll { public static void main(String[] args) { //declare variables for hourly rate and hours worked double hourlyRate; int hoursWorked; //Set tax rate as 0.15 (15 percent ) final double WITH_HOLD_TAX=0.15; //Set grossPay=0 double grossPay=0; //Set tax =0 double tax=0; //Set netPay=0 double netPay=0; //Create an instance of Scanner class Scanner inputScanner =new Scanner(System.in); System.out.println("Enter hourly rate of pay"); //prompt for hourly rate hourlyRate=Integer.parseInt(inputScanner.nextLine()); System.out.println("Enter number of hours worked"); //prompt for number of hours hoursWorked=Integer.parseInt(inputScanner.nextLine()); //Calculate grossPay //multiply hoursWorked by hourlyRate grossPay=hoursWorked*hourlyRate; //calculate with hold tax
  • 4. tax=grossPay*WITH_HOLD_TAX; //calculate netPay //subtract tax from grossPay netPay=grossPay-tax; //print gross pay and net pay to console System.out.println("Gross Pay : "+grossPay); System.out.println("Net pay : "+netPay); } } --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- Sample output: Enter hourly rate of pay 10 Enter number of hours worked 50 Gross Pay : 500.0 Net pay : 425.0