Write a program using an array. The array contains the hours worked for 5 employ
ID: 3554698 • Letter: W
Question
Write a program using an array.
The array contains the hours worked for 5 employees. These hours are entered by the user.All employees earn the same hourly wage. The program will calculate the gross pay for each employee. Hint: the gross pay for each employee (an element in an array) : array[index] * hourly wage
ask the user to enter the hours worked - refer to employee as employee 1,2,etc (see sample output)
- ask the use for the hourly wage
- display the gross pay for each employee
- display gross pay with 2 decimal places (not shown in sample output)
Explanation / Answer
//Doing This in Java.
//PM if you need anything else
//Cheers!
public class HourlyWage{
//The Main Method
public static void main(String args[]) throws IOException{
//Taking Input
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Please enter the hourly wage");
double input = Integer.parseInt(br.readLine());
double u= 0.00;
input = input + u;
double[] array = new double[5];
for(int i = 0; i<5;i++){
System.out.println("Please enter your hours Employee No. " + i);
array[i] = Integer.parseInt(br.readLine());
}
// Printing OUTPUT
for(int i = 0; i<5;i++){
array[i] = array[i]*input;
System.out.println("the gross pay for Employee No. " + i + "is " + array[i]);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.