[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

How do I write this in Perl?

Hi . . . I am a rookie Programming Student.  Just starting out.   I'm having trouble with my homework.   My program is working until I have to add some information.  This information is :  Pay Rate for hours > 40 and <= 45 = Time-and-a-half.
                        Pay Rate for hours > 45 = Double-time.

The fields in my file represent Employees Name, Hours worked, Pay Rate, and Gross Pay.
This is what I wrote . . . . .what did I do wrong . . .someone please tell me the correct way to write this!    Thank you!

if ($hoursworked <=40){
$grosspay = $hoursworked * $payrate;

} elsif ($hoursworked >40 and <=45){
$grosspay = $hoursworked * $payrate + 0.5 * $payrate * ($hoursworked - 40)

} elsif ($hoursworked >45){
$grosspay = $hoursworked * $payrate + 2.0 * $payrate * ($hoursworked - 40)
}
0
jmeyer34
Asked:
jmeyer34
1 Solution
 
pratap_rCommented:
you missed the variable name in your elsif condition

it should be

}elsif($hoursworked > 40 and $hoursworked <= 45){

and not

}elsif($hoursworked > 40 and <= 45){  #although this looks ok, it is not :-)

Have Fun!
Pratap
0
 
jmeyer34Author Commented:
Thank you very much!!   This is a great site!  It works!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now