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

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

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://991577]
Approved by marto
Front-paged by Arunbear
[marto]: good morning all
[Corion]: Hi marto!
[Corion]: The fun show at $work continues, as The Big Project is now in its second week of frantic live-bugfixing and weekend releases where nobody knows what went live. Nothing has been tested anyway.
erix mutters cantankerously under his breath
Corion watches from the sidelines. Or rather, from behind, as my system only gets output from that process and my programs adhere strictly to the GIGO design principle.
[erix]: ah, that's nice to hear Corion :)
[Corion]: erix: Yeah, the sad thing is that all I can do is document things, so I can point fingers when the auditors come :-/
[Corion]: "I'm here to open tickets and point fingers. And I'm all out of tickets."

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2017-03-28 08:51 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (328 votes). Check out past polls.