Computer Science, asked by poiuytre, 1 year ago

java programming. a security man is paid at hourly rate for the first 40 hours in a week. there after he is paid at 1.25 times of the hourly rate for the next 16 hours and at 1.5 the hourly rate for further hour work in a week. taking the number of hours (h) and rate (r) per hour calculate the weekly wages (w).

Answers

Answered by QGP
22

import java.util.Scanner;       //Importing Scanner

public class Brainly        

{

   public static void main(String[] args)

   {

       Scanner sc = new Scanner(System.in);    //Creating Scanner Object

       

       System.out.print("Enter number of hours: ");

       double hours = sc.nextDouble();     //Taking User Input for hours

       

       System.out.print("Enter rate per hour: ");

       double rate = sc.nextDouble();      //Taking User Input for rate

       

       double wages=0;         //Initialising wages to zero

       

       if(hours<=40)           //If hours<40, we simply multiply it with rate

       {

           wages = hours*rate;

       }

       else if(hours<=56)      //For more hours, we multiple excess of 40 hours with 1.25*rate

       {

           wages = 40*rate + (hours-40)*rate*1.25;

       }

       else            //For larger than 40+16 hours, we take the extra wages as well

       {

           wages = 40*rate + 16*rate*1.25 + (hours-56)*rate*1.5;

       }

       

       System.out.println("The weekly wages are "+wages);

   }

}

Attachments:
Similar questions