Create a non-GUI based java application that calculates weekly pay for an employee.?
Create a non-GUI based java application that calculates weekly pay for an employee.?
The application should display text that requests user input the name of employee, hourly rate, and number of hours worked for the week. The application should then print out the name of employee and the weekly pay amount. In the printout, display dollar symbol ($) to the left of weekly pay amount and format weekly pay amount to display currency.
import java.util.Scanner; // program uses class Scanner
class EmployeeProgram1App {
//main method begins execution of Java application
public static void main( String[] args) {
//create Scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
//variables declared
String Emp_name; //Store employee name
double Hours_worked; //Store hours worked
double PayRate; //Store Payrate
System.out.print( “Enter Employee’s name: ” ); //prompt
Emp_name = input.nextLine(); //read employee’s name entered by user
System.out.print( “Enter the pay rate of the Employee: ” ); //prompt…
Best answer:
PayRate = input.nextLine()
System.out.print(“Drop in the number of working hours”);
Hours_worked = input.nextLine();
double payAmount;
payAmount = Hours_worked * PayRate;
System.out.print(“Employee Name :” + Emp_name);
System.out.print(“$” + ” payAmount”);
}
p.s. you can add this line too :
System.out.print(” no pay amount, you are fired!”);
Tags: application, based, calculates, create, employee., java, nonGUI, weekly
Under Forum

1 Comment for Create a non-GUI based java application that calculates weekly pay for an employee.?
1. warsql | January 27th, 2007 at 7:20 am
PayRate = input.nextDouble();
System.out.print( “Enter the number of hours worked: ” ); //prompt…
Hours_worked = input.nextDouble();
System.out.println(
String.format(“%1$s $%2$.2f”,
Emp_name, Hours_worked * PayRate));
Leave a Comment for Create a non-GUI based java application that calculates weekly pay for an employee.?
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed