Write a java code that ask user to enter the time they clock in for work, and out for work and calculate their total hours for each day. Calculate the total hours for all five days. If the total hours is > or >= 12 then they are awesome, if not they are lazy. Thank you
I have written the program using JAVA PROGRAMMING LANGUAGE.
OUTPUT:
CODE:
//included java util all modules
import java.util.*;
class Main {//main class
public static void main(String[] args) {//main method
double total_hours = 0;//defined total_hours as 0
String arr[] = new String[] {"Monday","Tuesday","Wednesday","Thursday","Friday"};// days array
System.out.println("Please Enter the time based on 24 hours clock per day without using AM and PM\n");
Scanner input = new Scanner(System. in); //scanner object
//for loop for taking the in and out timings for all 5 working days
for(int i =0;i<5;i++){
System.out.println("\nFor "+arr[i]+" : \nIn Time : ");
Double in = input.nextDouble();
System.out.print("Out Time : ");
Double out = input.nextDouble();
total_hours += (out-in);
}
//to print the output on the console
System.out.println("\nOUTPUT : \nTotal hours worked : "+total_hours);
if(total_hours>12 || total_hours>=12){
System.out.println("Yes , You are AweSome!!!");
}else{
System.out.println("Sorry , You are Lazy!!!");
}
}
}
Thanks..
Get Answers For Free
Most questions answered within 1 hours.