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...

  • In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an...

    In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...

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
ADVERTISEMENT