Home
|
Ask Question
|
Interview Questions
|
Tech FAQ
s
|
Engineering
|
Company
|
Geek Forums
|
Interview Coaching
|
Online Quiz
|
Interview eBook
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
MainFrame
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:
3539 times
Filed in:
Perl
Add Comment
Sponsored Links
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
♦
PassCripting - Crypt Perl Password
♦
Currency Converter
♦
Simple PerlScript Loop
♦
PerlScript Array
Related Code Samples
»
RTF 2 HTML Converter
Post Your Comment:
Members Please Login
Your Name:
*
e-mail ID:
(required for notification)
*
Image Verification:
Subscribe
Popular Coders
#
Coder Name
Hits
1.
srinivasaraobora
17408
Active Coders
#
Coder Name
Codes
1.
srinivasaraobora
5
Refined Tags
Copyright © 2012 GeekInterview.com | All Rights Reserved