Home
Tech Articles
Code Samples
Learn
Freelance Projects
Online Testing
Geek Talk
Job Postings
Knowledge Base
Geek Blogs
Question Bank
Interview Questions
Certification
Placement Papers
Tech FAQ
Career Advice
Engineering
Ask Question
I am new,
Sign me up!
User Name
Remember Me?
Password
Code Base
Submit Code
Back
Oracle
PHP
Java
ASP.NET
C#
Delphi
VB.NET
Perl
ColdFusion
SQL Server
MySQL
C
C++
UNIX
AJAX
Flash
HTML
CSS
Java Script
VB Script
XML
Python
MS Access
Perl Code Base
•
PassCripting - Crypt Perl Password
•
Currency Converter
•
PerlScript Array
•
PerlScript HTML Form
•
Simple PerlScript Loop
Code Samples
Perl
Currency Converter
Code Resource
Author:
srinivasaraobora
Difficulty Level
: Intermediate
Published:
25th Apr 2009
Read:
1236 times
Filed in:
Perl
Add Comment
This code shows Currency converter Please enter the Yen to pound exchange
Sample Code
#!/usr/bin/perl
#Ex2_1.plx
use
warnings
;
use
strict
;
print
"Currency converternnPlease enter the Yen to pound exchange rate: "
;
my
$yen
=
<STDIN>
;
#Prompt user to input amounts, and do the conversions:
print
"Now please enter your first amount: "
;
my
$first
=
<STDIN>
;
my
$a
=
(
$first
/
$yen
)
;
print
"Enter your second amount: "
;
my
$second
=
<STDIN>
;
my
$b
=
(
$second
/
$yen
)
;
print
"Enter your third amount: "
;
my
$third
=
<STDIN>
;
my
$c
=
(
$third
/
$yen
)
;
#turn the results into values with no more than 2 decimal places, and rounded #to 2 places too.
my
$mod1
=
(
int
(
100
*
$a
)
/
100
)
;
my
$mod2
=
(
int
(
100
*
$b
)
/
100
)
;
my
$mod3
=
(
int
(
100
*
$c
)
/
100
)
;
#Get rid of trailing newline character:
chomp
(
$first
,
$second
,
$third
)
;
#print out answers with two decimal place accuracy:
printf
(
"$first Yen is %.2f poundsn"
,
$mod1
)
;
printf
(
"$second Yen is %.2f poundsn"
,
$mod2
)
;
printf
(
"$third Yen is %.2f poundsn"
,
$mod3
)
;
Copyright GeekInterview.com
Next Article:
PassCripting - Crypt Perl Password
Latest Code Samples
♦
PerlScript HTML Form
♦
Currency Converter
♦
Simple PerlScript Loop
♦
PerlScript Array
♦
PassCripting - Crypt Perl Password
Popular Code Samples
♦
PerlScript HTML Form
♦
Currency Converter
♦
Simple PerlScript Loop
♦
PassCripting - Crypt Perl Password
♦
PerlScript Array
Related Code Samples
»
RTF 2 HTML Converter
Post Comment
Members Please Login
Name:
Email:
(Optional. Used for Notification)
Title:
Comment:
Validation Code:
<=>
(Enter this code in text box)
Popular Coders
#
Coder Name
Hits
1.
srinivasaraobora
5409
Active Coders
#
Coder Name
Codes
1.
srinivasaraobora
5
Refined Tags
Sponsored Links
About Us
-
Privacy Policy
-
Terms and Conditions
-
Contact
Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved