Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/perl
- #Numeric values are assigned to the variables to represent the costs of a car, home, and the total money.
- $house = 150000;
- $car = 15000;
- $totalmoney = 300000;
- print "";
- #Calculates and prints the total cost of the car and home.
- $total = $house + $car;
- print 'The cost of the house and car together is:$'. $total . "\n";
- #Calculates and prints the amount of money left after the car and home is bought.
- $total = $totalmoney - $house - $car;
- print 'After you buy a house and car you have this much money left:$' . $total . "\n";
- #Calculates and prints the number of cars you're able to buy with the money available.
- $total = $totalmoney/$car;
- print 'You can have this many cars with your money:' . $total . "\n";
- #Calculates and prints the number of homes you're able to buy with the money available.
- $total = $totalmoney/$house;
- print 'You can have this many homes with your money:' . $total . "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement