English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1. Modify the Payroll Program application so it continues to request employee information until the user enters stop as the employee name.

2. In addition, program the application to check that the hourly rate and number of hours worked are positive numbers. If either the hourly rate or the number of hours worked is not a positive value, the application should prompt the user to enter a positive amount.

here is my code...

import java.text.NumberFormat;
import java.util.Scanner;
import java.util.Locale;

public class PayrollProgram {

public static void main(String[] args)
{

Scanner input = new Scanner( System.in );
NumberFormat usFormat = NumberFormat.getCurrencyInstance();

String fName;
String lName;
double hourlyRate = 0.0;
int hours = 0;

System.out.println("Enter the following info for the employee: ");
System.out.println("First name: ");fName = input.next();
System.out.println("Last name: ");lName = input.next();
System.out.println("Hourly rate: ");hourlyRate = Double.parseDouble(input.next());
System.out.println("Hours worked this week: ");hours = Integer.parseInt(input.next());

System.out.println("Here is the employee's info: ");
System.out.println("Name: " + fName + " " + lName);
System.out.println("Weekly Pay: " + usFormat.format(hourlyRate * hours));

}
}

2007-11-14 10:52:18 · 5 answers · asked by Anonymous in Computers & Internet Programming & Design

5 answers

Wish I knew something about Java... but don't sorry...

good luck!

2007-11-14 10:58:53 · answer #1 · answered by Anonymous · 0 2

Sorry. I dont know Java. But, I can give you some help with pseudocode.

Problem 1 is saying to create a loop (while, do while, etc). The loop terminator condition will be the word "STOP".

While Var1 <> "STOP"
'Do Proceessing
Var1 = "Enter student Name. Enter "STOP" to quit."
Wend

For problem 2,
WHILE (Hours < 0)
messagebox "Hours must be positive number."
Hours = 'however you prompt user for hours.
WEND

WHILE (HourlyRate < 0)
MessageBox "Hourly rate must be greater than zero you moron!"
HourlyRate = 'however you prompt user for hourly rate"
WEND

Good luck.

2007-11-14 11:07:14 · answer #2 · answered by Anonymous · 0 0

Hi. Your check for a 'stop' should occur just after this line.
"System.out.println("First name: ");fName = input.next();"
Otherwise you will need to enter all fields first. Remember that the hours worked may not be an integer. (6.5)

2007-11-14 11:03:44 · answer #3 · answered by Cirric 7 · 0 0

Your code is valid. What for you want to change? { //right here statements proclaims variables flow temp_c, temp_f,temp_k; //right here's consumer interface fact which informs what the consumer has to enter printf ("enter the linked fee of Temperature in Celcius: "); //right here fact is to study the consumer enter right into a vairbale temp_c scanf ("%f", &temp_c); //This to calculated equivalent Fahrenheit temperature temp_f = (a million.8* temp_c) + 32; //that is to calculate equivalent kelvin temperature temp_k = temp_c +273.15; //right here 2 strains are meant for printing the calculated Fahrenheit and kelvin temperatures printf ("the linked fee of Temperature in Fahreinheit is: %.2fn", temp_f); printf ("the linked fee of Temperature in Kelvin is: %.2f", temp_k);

2016-10-24 06:14:42 · answer #4 · answered by ? 3 · 0 0

ok wat r u talking about ur weird

2007-11-14 10:55:55 · answer #5 · answered by Anonymous · 0 2

fedest.com, questions and answers