please help me think of a simple programing question. For this discussion board,
ID: 3744576 • Letter: P
Question
please help me think of a simple programing question.
For this discussion board, you will pose one question related to developing algorithms and working with variables, only using sequence (no selection or repetition). Your question must require a pseudocode solution to a problem (requiring between 10-20 lines of code). Before you post the problem you have created, make sure you are able to solve the problem yourself using only the course materials in no fewer than 10 lines of code and no more than 20 lines of code.
Explanation / Answer
Problem: To store the employee information with empID,name, no of working hours, rate of payment per hours, calculate the gross pay, calculate taxes payable and pf deeduction, calculate total deduction and the net salary payable.
Algorithm:
Start
Declare the variables
String name
int noOfHours, rateOfHours
float grosspay,netpay,tax,pf, totalDeduction;
output "Enter the Employee name"
input name
output "Enter no of hours"
input noOfHours
Output "Entr rate"
input rateOfHours
calculate grosspay=noOfHours*rateOfHours
calculate tax=(grosspay*10)/100
calculate pf=(grosspay*12)/100
calculate toralDeduction=tax+pf
calculate netpay=grosspay-total deduction
output grosspay, totalDeduction, netpay
end
Program
EmployeeDetail.java
//driver class
public class EmployeeDetail{
//main function
public static void main(String[] args) {
//Creating object of scanner to take input from the user
Scanner inp=new Scanner(System.in);
//decalring required variable for storing input
String name;
int noOfHours = 0,hourlyRate = 0;
double grossPay,netPay,pf,tax,totDeduction;
//asking user for required inputs
System.out.print("Enter name=");
name=inp.nextLine();
System.out.print("Enter no of hours=");
noOfHours=inp.nextInt();
System.out.print("Enter rate per hourse=");
hourlyRate=inp.nextInt();
//calculating basic pay of the employee
grossPay=noOfHours*hourlyRate;
//calculating tax asuuming to be 10%
tax=(grossPay*10)/100;
//calculating pf deduction at 12%
pf=(grossPay*12)/100;
//calculating gross payement by subtracting the deduction for taxes, pf
totDeduction=(tax+pf);
//showing the deduction and calculated salary to the user
netPay=grossPay-totDeduction;
System.out.println("Basic salary of "+name+" working for "+noOfHours+" hours at rate of $"+hourlyRate+" is =$"+grossPay);
System.out.println("Gross Salary after deducting state tax $"+tax+", pf deduction $"+pf+" payable salary is =$"+netPay);
}
}
Output:
Enter name= scott
Enter no of hours=10
Enter rate per hourse=100
Basic salary of scott working for 10 hours at rate of $100 is =$1000.0
Gross Salary after deducting state tax $100.0, pf deduction $120.0 payable salary is =$780.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.