| Script language | Running the script | Interpreter version |
| perl | perl (or ./) hellop.pl | v. 5.8.7 |
| python | python (or ./) hellopython.py | v. 2.4.3 |
| tcl | tclsh (or ./) hellotcl.tcl | 8.3 & 8.4 |
| ruby | ruby (or ./) hellor.rb | v. 1.8.4 |
| rexx | rexx (./) hellor.rexx | regina v.3.3.5.00 |
| tk | wish hellotk.tcl | v. 8.3 & 8.4 |
| haskell | hugs or ghci then the filename with .hs extension. Evaluate the expression (or function) by typing its name, eg. hugs (or ghci) hellointer.hs, hit enter and type hellointer (to evaluate the expression or function) | hugs v. 20050308 or ghci v. 6.4.1 |
#!/usr/bin/perl
while ($q==0){
print "enter 1 for area of a square,\n2 for area of a rectangle,\n3 for area of a circle and 4 to quit: \n\n";
$choice=;
print("\n");
if($choice == 1) {
print ("enter base length of square: \n");
$noe=;
$req=$noe*$noe;
print ("the area = $req\n");
format printtosc =
********************************************************************************
The Result
area =@>>>>
$req
********************************************************************************
.
$~="printtosc";
write(STDOUT);
print ("to save result to data file, enter 1: ");
$fchoice=;
if ($fchoice==1) {
print ("to append file enter 1 & to ovewrite/create, enter 2: ");
$appover=;
if ($appover==1){
format printtofile =
==================================================================================
area =@>>>>
$req
==================================================================================
.
print ("enter file name: ");
$filenam=;
open(myfile,">>$filenam");
select(myfile);
$~="printtofile";
write(myfile);
close(myfile);
select(STDOUT);
}
elsif ($appover==2){
print ("enter file name: ");
$filenam=;
open(myfile,">$filenam");
select(myfile);
print ("the equivalent = $req\n");
print("the $noe elements are: $el1, $el2 & $ el3");
close(myfile);
select(STDOUT);
}
}
}
elsif($choice == 2) {
print ("enter base length of rectangle: \n");
$noe=;
print ("enter height of rectangle: \n");
$noe1=;
$req=$noe*$noe1;
print ("the area = $req\n");
}
elsif($choice == 3) {
print ("enter radius of circle: \n");
$noe=;
$req=$noe*$noe*3.14159;
print ("the area = $req\n");
}
elsif($choice == 4) {last;}
}
#!/usr/bin/python
print "areas"
choice =""
while choice != "q":
print "enter choice: a for a square area, b a rectangle, c for a circle area and q to quit"
choice = raw_input()
if choice == "a":
print "a square area"
print "base length of square"
base = float(raw_input())
area=(base*base)
print "the area of square = ",area
print "overwrite enter o, append enter a"
appover = raw_input()
if appover == "o":
print "enter file name"
fnam = raw_input()
f=open(fnam, 'w')
f.write ('\nthis is to overwrite or create\n')
f.write (area)
f.close()
if appover == "a":
print "enter file name"
fnam = raw_input()
f=open(fnam, 'a')
f.write ('\nthis is to append\n')
f.write (area)
f.close()
if choice == "b":
print "rectangle area"
print "base length of rectangle"
base = float(raw_input())
print "height of rectangle"
height = float(raw_input())
area=(height*base)
print "the area of rectangle = ",area
if choice == "q":
break
#!/usr/bin/tclsh
proc square {} {
puts "base length of square eg 2.0: "
set el1 [gets stdin]
set res [expr ($el1*$el1)]
puts "the area = $res"
puts "to save to data file: to overwrite enter 1; to append enter 2 (press enter key to skip)"
set overappe [gets stdin]
if {$overappe == 1} {
puts "overwrite, enter filename to create/overwrite"
set filenam [gets stdin]
set fileid [open $filenam w]
puts $fileid "the base length & area are: $el1, $res"
close $fileid
}
if {$overappe == 2} {
puts "append, enter filename to append"
set filenam [gets stdin]
set fileid [open $filenam a]
puts $fileid "the base length & area are: $el1, $res"
close $fileid
}
}
proc circle {} {
puts "radius of circle eg 2.0: "
set el1 [gets stdin]
set res [expr ($el1*$el1*3.14159)]
puts "the area = $res"
puts "to save to data file: to overwrite enter 1; to append enter 2 (press enter key to skip)"
set overappe [gets stdin]
if {$overappe == 1} {
puts "overwrite, enter filename to create/overwrite"
set filenam [gets stdin]
set fileid [open $filenam w]
puts $fileid "the radius and area are: $el1, $res"
close $fileid
}
if {$overappe == 2} {
puts "append, enter filename to append"
set filenam [gets stdin]
set fileid [open $filenam a]
puts $fileid "the radius and area are: $el1, $res"
close $fileid
}
}
proc rectangle {} {
puts "base length of rectangle according to following format nn.nn eg. 3.0: "
set el2 [gets stdin]
puts "height of rectangle per above indicated format: "
set el1 [gets stdin]
set result0 [expr ($el2*$el1)]
puts "the area = $result0"
puts "to save to data file: to overwrite enter 1; to append enter 2 (press enter key to skip)"
set overappe [gets stdin]
if {$overappe == 1} {
puts "overwrite, enter filename to create/overwrite"
set filenam [gets stdin]
set fileid [open $filenam w]
puts $fileid "the height, base length and area are: $el1, $el2, $result0"
close $fileid
}
if {$overappe == 2} {
puts "append, enter filename to append"
set filenam [gets stdin]
set fileid [open $filenam a]
puts $fileid "the height, base length and area are: $el1, $el2, $result0"
close $fileid
}
}
set choice ""
while {$choice != "q"} {
puts -nonewline "Enter a for area of a square, \nb for area of rectangle, \nc for area of circle & q to exit: "
set choice [gets stdin]
if {$choice == "a"} {square}
if {$choice == "b"} {rectangle}
if {$choice == "c"} {circle}
if {$choice == "q"} {
exit}
}
#!/usr/bin/ruby quit = 0 while quit == 0 print "enter 1 for area of a square, 2 for area of rectangle, 3 for area of circle and 4 to quit\n" choice = STDIN.gets.chomp.to_i if choice == 1 then print "area of a square\n" print "enter base length of square\n" a = STDIN.gets.chomp.to_f c = a*a print "area of square = ",c,"\n" elsif choice == 2 then print "area of a rectangle\n" elsif choice == 3 then print "area of a circle\n" print "enter radius of circle\n" a = STDIN.gets.chomp.to_f c = a*a*3.14159 print "area of circle = ",c,"\n" elsif choice == 4 then quit = 1 end end
#!/usr/bin/rexx quit = 0 do while quit = 0 say "enter 1 for area of a square, 2 for area of a rectangle, 3 area of a circle and 4 to quit" pull a if a = 1 then do say "enter base length of square" pull b c = b*b say "area of square = " c end if a = 2 then do say "area of a rectangle" say "enter base length of rectangle" pull b say "enter height of rectangle" pull b1 c = b*b1 say "area of rectangle = " c end if a = 3 then do say "area of a circle" say "enter radius of circle" pull b c = b*b*3.14159 say "area of circle = " c end if a = 4 then do quit = 1 end end
