Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: subtracting numbers

by marto (Cardinal)
on Dec 23, 2020 at 10:40 UTC ( [id://11125670]=note: print w/replies, xml ) Need Help??


in reply to subtracting numbers

Welcome. If this is a homework or exercise question it may help to post the actual challenge. Assuming that you want to prompt the user to enter one number, then subtract from that a number depending on user input value, try something like this.

#!/usr/bin/perl use strict; use warnings; print "Enter a number\n"; my $number = <>; chomp($number); my $sendthis = ''; if ( $number ) { if ( $number >= 50 ) { $sendthis = $number - 4; } elsif ( $number >= 20 ) { $sendthis = $number - 3; } elsif ( $number >= 10 ) { $sendthis = $number - 2; }else{ $sendthis = $number; } } print "You sent: $sendthis\n";

Replies are listed 'Best First'.
Re^2: subtracting numbers
by frank1 (Beadle) on Dec 23, 2020 at 11:27 UTC

    i appreciate

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125670]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-16 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found