Exercise: Calculate the area of a rectangular

Write a program that computes the area of a rectangular.

  • Start by having two hard coded values. Multiply them and print the result. The result should be 42:
    $ perl example.pl
    42
    
  • Then change the code to prompt the user for two numbers. Multiply them and print the result:
    $ perl example.pl
    First number: 7
    Second number: 6
    42
    
    # ruby example.rb
    First number: 3
    Second number: 11
    33
    
  • Further modify the program to warn if one of the numbers given was negative.
    $ python example.py
    First number: 3
    Second number: -1
    Warning: Invalid input. The side of a rectangular cannot be negative.