In: Computer Science
Please can you draw a flow chart for the following code :
Program code for Payroll,java:
public class Payroll
{
public Payroll(String name,int ID,double payRate)
{
this.name=name;
this.ID=ID;
this.payRate=payRate;
}
private String name;
private double payRate,hrWorked;
private int ID;
public Payroll()
{
name="John Doe";
ID=9999;
payRate=15.0;
hrWorked=40;
}
public String getName()
{
return name;
}
public int getID()
{
return ID;
}
public void setPayRate(int payRate)
{
this.payRate=payRate;
}
public void setHrWorked(double hrWorked)
{
this.hrWorked=hrWorked;
}
public double getPayRate()
{
return payRate;
}
public double getHrWorked()
{
return hrWorked;
}
public double grossPay()
{
double grosspay=hrWorked*payRate;
return grosspay;
}
}
Program code for PayrollClient.java:
import java.util.Scanner;
class main
{
public static void main(String [] args)
{
Scanner read=new Scanner(System.in);
System.out.print("\nEnter Name:");
String name=read.next();
System.out.print("\nEnter ID:");
int ID=read.nextInt();
System.out.print("\nEnter Payrate:");
double payRate=read.nextDouble();
Payroll obj1=new Payroll(name,ID,payRate);
System.out.print("\nEnter Hours worked:");
double hrWorked=read.nextDouble();
obj1.setHrWorked(hrWorked);
Payroll obj2=new Payroll();
System.out.println("Employee details are:");
System.out.println("Name\t
ID\tPayRate\tHoursWorked\tGrossPay");
System.out.println(obj1.getName()+"
"+obj1.getID()+"\t"+obj1.getPayRate()+"\t"+obj1.getHrWorked()+"\t\t"+obj1.grossPay());
System.out.println(obj2.getName()+"
"+obj2.getID()+"\t"+obj2.getPayRate()+"\t"+obj2.getHrWorked()+"\t\t"+obj2.grossPay());
}
}
Answer-
Flow Chart for the Payroll.java ⇒
There are five function or class used in this flow Chart-
Payroll()-
getID()-
setPayRate()-
getHrWorked()-
grossPay()-
Flow Chart for the PayrollClient.java-
Note- Please do upvote, if any problem then comment in
box sure I will help.