Question

Create an applet payroll program named CalcPay that allows the user to enter two double valuesand...

Create an applet payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay by pressing CALCULATE button. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output which should include: Name, hours, rate, deduct, gross and net.

please write program in java only with output

thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

[1:34 PM, 2/7/2019] BZa: import java.io.*;
import java.awt.*;
import java.awt.Color.*;
import java.awt.event.*;
import java.applet.*;


/<applet code=train2.class height=300 width=600></applet>/


public class train2 extends Applet implements
ActionListener,ItemListener

{
Label name,amount,seats,number;
TextField na,am,sts,nr;
TextArea t;
Choice css;

Checkbox si,sr;
CheckboxGroup g;

Button b,cancel;
int s,c,d;
int n1=400;
int n2=250;
int n3=100;

public void init()
{
setBackground(Color.yellow);
setForeground(Color.red);
setLayout(new FlowLayout());

na=new TextField(20);
am=new TextField(20);
sts=new TextField(20);
nr=new TextField(20);


name=new Label("NAME");
amount=new Label("AMOUNT");
seats=new Label("SEATS");
number=new Label("REQUIRED NO OF SEATS");

css=new Choice();
css.add("A.C SLEEPER");
css.add("FIRST CLASS");
css.add("SECOND CLASS");

t=new TextArea(40,45);

g=new CheckboxGroup();
si=new Checkbox("SATAPTI",g,false);
sr=new Checkbox("SABARI",g,false);

b=new Button("SUBMIT");
cancel=new Button("CANCEL");

add(name);
add(na);

add(seats);
add(sts);

add(number);
add(nr);


add(si);
add(sr);

add(css);

add(b);

add(amount);
add(am);

add(t);
add(cancel);

css.addItemListener(this);
b.addActionListener(this);
si.addItemListener (this);
sr.addItemListener (this);


}
public void actionPerformed(ActionEvent ae)
{

if(b.getActionCommand().equals("SUBMIT"))
{
d=Integer.parseInt(nr.getText());
s=(Integer.parseInt(sts.getText()))-d;

if(css.getSelectedItem().equals("A.C SLEEPER"))
{
am.setText("400");
}
else if(css.getSelectedItem().equals("FIRST CLASS"))
{
am.setText("250");
}
else
{
am.setText("100");
}

}

  
c=((Integer.parseInt(am.getText()))*(Integer.parseInt(nr.getText())));
t.setText("NAME:"+na.getText()+"
"+"After reservation total no.of
seats are:"
+s+"
"+"Train name
:"+g.getSelectedCheckbox().getLabel()+"
"+"Class:"+
css.getSelectedItem()+ "Total number of Rs :"+c);

if(cancel.getActionCommand().equals("CANCEL"))
{
repaint();
}

}

public void itemStateChanged(ItemEvent ie)
{

}

}

import java.io.*;
import java.awt.*;
import java.awt.Color.*;
import java.awt.event.*;
import java.applet.*;


/<applet code=train2.class height=300 width=600></applet>/


public class train2 extends Applet implements
ActionListener,ItemListener

{
Label name,amount,seats,number;
TextField na,am,sts,nr;
TextArea t;
Choice css;

Checkbox si,sr;
CheckboxGroup g;

Button b,cancel;
int s,c,d;
int n1=400;
int n2=250;
int n3=100;

public void init()
{
setBackground(Color.yellow);
setForeground(Color.red);
setLayout(new FlowLayout());

na=new TextField(20);
am=new TextField(20);
sts=new TextField(20);
nr=new TextField(20);


name=new Label("NAME");
amount=new Label("AMOUNT");
seats=new Label("SEATS");
number=new Label("REQUIRED NO OF SEATS");

css=new Choice();
css.add("A.C SLEEPER");
css.add("FIRST CLASS");
css.add("SECOND CLASS");

t=new TextArea(40,45);

g=new CheckboxGroup();
si=new Checkbox("SATAPTI",g,false);
sr=new Checkbox("SABARI",g,false);

b=new Button("SUBMIT");
cancel=new Button("CANCEL");

add(name);
add(na);

add(seats);
add(sts);

add(number);
add(nr);


add(si);
add(sr);

add(css);

add(b);

add(amount);
add(am);

add(t);
add(cancel);

css.addItemListener(this);
b.addActionListener(this);
si.addItemListener (this);
sr.addItemListener (this);


}
public void actionPerformed(ActionEvent ae)
{

if(b.getActionCommand().equals("SUBMIT"))
{
d=Integer.parseInt(nr.getText());
s=(Integer.parseInt(sts.getText()))-d;

if(css.getSelectedItem().equals("A.C SLEEPER"))
{
am.setText("400");
}
else if(css.getSelectedItem().equals("FIRST CLASS"))
{
am.setText("250");
}
else
{
am.setText("100");
}

}

  
c=((Integer.parseInt(am.getText()))*(Integer.parseInt(nr.getText())));
t.setText("NAME:"+na.getText()+"
"+"After reservation total no.of
seats are:"
+s+"
"+"Train name
:"+g.getSelectedCheckbox().getLabel()+"
"+"Class:"+
css.getSelectedItem()+ "Total number of Rs :"+c);

if(cancel.getActionCommand().equals("CANCEL"))
{
repaint();
}

}

public void itemStateChanged(ItemEvent ie)
{

}

}

Add a comment
Know the answer?
Add Answer to:
Create an applet payroll program named CalcPay that allows the user to enter two double valuesand...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a payroll program named CalcPay that allows the user to enter two double valuesand a...

    Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output. The...

  • Create a payroll program named CalcPay that allows the user to enter two double valuesand a...

    Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output. The...

  • use at least two functions in your program. . Write a program that calculates weekly payment....

    use at least two functions in your program. . Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate....

  • Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user...

    Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user for type of employee (hourly ("h"or "H") or management ("'m" or "M") If the employee is management: . get the annual salary get the pay period (weekly ("w" or "W"), bi-weekly ("b" or "B") or monthly ("m" or e compute the gross salary for the pay period (Divide annual salary by 52 for weekly, 26 for bi-weekly, and 12 for monthly) deduct from gross...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for...

    ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for employees. Specifications Create an abstract Employee class that provides private attributes for the first name, last name, email address, and social security number. This class should provide functions that set and return the employee’s first name, last name, email address, and social security number. This class has a function: get_net_income which returns 0. Create a Manager class that inherits the Employee class. This class...

  • It's my python assignment. Thank you You wrote a program to prompt the user for hours...

    It's my python assignment. Thank you You wrote a program to prompt the user for hours and rate per hour to compute gross pay. Also your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours. Enter Hours: 45 Enter Rate: 10 Pay: 475.0 (475 = 40 * 10 + 5 * 15) Rewrite your pay program using try and except so that your program handles non-numeric input gracefully. Enter Hours: 20 Enter...

  • Write a c++ program to create a payroll based on these assumptions and requirements: A company...

    Write a c++ program to create a payroll based on these assumptions and requirements: A company called Data Housing Corp. employs a number of employees (say 5) all employees are paid on hourly base, any employee who works more than 40 hours is entitled to be paid overtime (1.5 for every hour exceeding 40). Calculate : 1. The Gross income=(Rate*hours worked )+ overtime 2. The overtime= No. of hours exceeding 40 * Rate *1.5 3. State tax= gross*6% 4.Federal tax=gross*12%...

  • Questions:(to be answered within the video) Write a C++ program with the following specifications: 1. Create...

    Questions:(to be answered within the video) Write a C++ program with the following specifications: 1. Create a class and name it Payslip. This class should have the following attributes or properties: name,pay grade, basic salary, overtime hours, overtime pay, gross pay, net pay and withholding tax. 2. Define the accessors and mutators of the Payslip class based on its attributes or properties.  This class should also have the following methods: determinePayGradeAndTaxRate and computePay. 3. Create another class and name it Employee.  This...

  • Create one program using these three programs: 1. Payroll Calculator Need to include state tax amount...

    Create one program using these three programs: 1. Payroll Calculator Need to include state tax amount and SS amount Net pay need to reflect those amount Need to make all the amounts with 2 decimal points. Hint See line #31 - Use the programming outline/format discussed in the lecture, with proper documentation, data declaration, etc. - When asking a user for data, provide user-friendly and clear direction - Same thing for the output. - Include code and screenshot of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT