首页 > 其他 > 详细

perl practice

时间:2021-06-25 10:04:32      阅读:16      评论:0      收藏:0      [点我收藏+]

perl practice

人民币/美金根据汇率进行转换

print<<EOF;

This is a currency convert program;
    
please input the exchange rate and select the local currency;
    
EOF

print "please input the exchange rate between dollar and RMB","\n";

chomp(my $exchange_rate = <STDIN>);

print "the exchange rate you set is $exchange_rate","\n";

print "please select RMB or dollar as your local currency","\n";

chomp(my $currency = <STDIN>);

print "you set $currency as you local currency","\n";

if($currency eq "RMB") {
    
    print "please input the amount of your local currency","\n";
    
    chomp(my $amount = <STDIN>);
    
    print "the amount of RMB is $amount","\n";
    
    print "RMB convert to dollar,the amount is ",$amount/$exchange_rate;
    
} elsif($currency eq "dollar") {
    
    print "please input the amount of your local currency","\n";
    
    chomp(my $amount = <STDIN>);
    
    print "the amount of dollar is $amount","\n";
    
    print "dollar convert to RMB,the amount is ",$amount*$exchange_rate;
    
} else {
    
    print "the currency you set is wrong","\n";
    exit;
    
}

技术分享图片

perl practice

原文:https://www.cnblogs.com/movit/p/14929341.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!