zoukankan      html  css  js  c++  java
  • perl practice

    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","
    ";
    
    chomp(my $exchange_rate = <STDIN>);
    
    print "the exchange rate you set is $exchange_rate","
    ";
    
    print "please select RMB or dollar as your local currency","
    ";
    
    chomp(my $currency = <STDIN>);
    
    print "you set $currency as you local currency","
    ";
    
    if($currency eq "RMB") {
        
        print "please input the amount of your local currency","
    ";
        
        chomp(my $amount = <STDIN>);
        
        print "the amount of RMB is $amount","
    ";
        
        print "RMB convert to dollar,the amount is ",$amount/$exchange_rate;
        
    } elsif($currency eq "dollar") {
        
        print "please input the amount of your local currency","
    ";
        
        chomp(my $amount = <STDIN>);
        
        print "the amount of dollar is $amount","
    ";
        
        print "dollar convert to RMB,the amount is ",$amount*$exchange_rate;
        
    } else {
        
        print "the currency you set is wrong","
    ";
        exit;
        
    }
    

    ATM

    
    my $info = <<"EOF";
    
    The amount must can divide by 5;
    
    Your account should be great than your amount;
    
    Every time need pay 0.5 dollar for Handling fee;
    
    original link: https://www.codechef.com/problems/HS08TEST
    
    EOF
    
    print $info;
    
    print "Please input the amount you wanna get","
    ";
    
    chomp(my $amount = <STDIN>);
    
    print "the amount you input is $amount
    ";
    
    print "Please input the account amount you have","
    ";
    
    chomp(my $account = <STDIN>);
    
    print "the account amount you have is $account
    ";
    
    if($amount%5 != 0) {
    	
    	print "The amount you input cant divide by 5
    ";
    	
    } elsif($amount > $account) {
    	
    	print "you account is not enough for you amount
    ";	
    		
    } else {
    
    	print "Please wait a moment,tou will get $amount dollar
    ";
    	
    	print "Now your account have ",$account-$amount-0.5," dollar
    ";
    	
    }
    
    

  • 相关阅读:
    weblogic的ssrf漏洞
    web服务器、Web中间件和Web容器的区别
    linux C判断文件是否存在
    Linux 文件锁flock 实现两个进程相互监听存活状态
    Linux 进程间通信之管道(pipe),(fifo)
    Linux 进程间通信系列之 信号
    android Binder机制(一)架构设计
    Linux 系统 文件锁 fcntl函数详解
    execlp启动android进程命令
    Linux环境编程--waitpid与fork与execlp
  • 原文地址:https://www.cnblogs.com/movit/p/14929341.html
Copyright © 2011-2022 走看看