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.

2007-11-14 06:24:55 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

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 06:28:02 · update #1

can anyone modify it for me?
please!!!

2007-11-14 06:38:21 · update #2

2 answers

1) Put the input request into a while loop. Have that loop check the input to see if the string "stop" is entered, otherwise process the entry.

2) This is a simple conditional check to see if the input values are greater than 0. It sounds like the prompt could be setup as a loop that executes until a positive value is entered.

** Edit **
I'm sure your teacher would rather see your work than mine to modify the code. What I can do is point you to some examples though that you can apply to your specific code. In both cases, you want to use a looping technique. For the first you'll loop until the input is "stop", the second is a loop until a valid positive number is entered.

2007-11-14 06:31:04 · answer #1 · answered by Jim Maryland 7 · 1 0

Sorry i do not understand what you are trying to do?


Monify a programe is very dificult! Creating HTML strigs can be difficult (e.g. F00000 , etc) and that is easy compared to progrme modifing!

2007-11-14 06:31:07 · answer #2 · answered by sean_turner_uk 2 · 0 3

fedest.com, questions and answers