Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Cycle Gear Ratio Calculator

by fatmac (Acolyte)
on Sep 04, 2012 at 09:17 UTC ( #991577=CUFP: print w/ replies, xml ) Need Help??

With the help of, & grateful thanks to Gangabass, Athanasius, GrandFather, philiprbrenan, & ww. I offer my first proper Perl program to anyone who may like to use it. Cycle Gear Ratio Calculator
#!/usr/bin/perl use strict; use warnings; my $fh = \*STDIN; # For test input, change to: \*DATA ###my $fh = \*DATA; # For user input, change to: \*STDIN print "\nMulti Gear Calculator\n\n"; print "Enter Wheelsize (inches): "; my $wheel = <$fh>; print $wheel; chomp $wheel; print "Enter Chainwheel Teeth: "; my $chainWheels = <$fh>; print $chainWheels; my @chainWheels = split /\s+/, $chainWheels; print "Enter Cog Teeth: "; my $cogs = <$fh>; print $cogs; my @cogs = split /\s+/, $cogs; print "Wheelsize: $wheel\n"; print "Chainwheels: @chainWheels\n"; print "Cogs: @cogs\n\n"; for my $chainSel (1 .. @chainWheels) { my $wheelMul = $wheel * $chainWheels[$chainSel - 1]; print "Chain wheel: $chainSel ratios: \n"; for my $cogSel (1 .. @cogs) { printf "%5.2f ", $wheelMul / $cogs[$cogSel - 1]; } print "\n"; } __DATA__ 26.5 42 32 22 11 13 15 17 19 21 24 28 32

Comment on Cycle Gear Ratio Calculator
Download Code
Re: Cycle Gear Ratio Calculator
by davido (Archbishop) on Sep 04, 2012 at 18:06 UTC
      That was interesting, especially as they also were reading the same book when they coded it. This is my single gear calculator code:
      #!/usr/bin/perl use strict; use warnings; print "\nGear Calculator\n\n"; print "Enter Wheelsize (inches): "; my $wheel = <>; print "Enter Chainwheel Teeth: "; my $teeth = <>; print "Enter Cog Teeth: "; my $cog = <>; my $gear = $wheel * $teeth / $cog; print "\nYour gear is: ", $gear, "\n\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://991577]
Approved by marto
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-12-22 23:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (133 votes), past polls