Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Syntactic Confectionery Delight
 
PerlMonks  

CAN YOU FIGURE THIS OUT?

by PERLVICE (Initiate)
on Mar 29, 2005 at 18:21 UTC ( [id://443302]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

PERLVICE has asked for the wisdom of the Perl Monks concerning the following question:

How Cold is it? Physicists tell us that the lowest possible temperature is absolute zero. Absolute zero is -459.69 degrees Fahrenheit. a. Accept input from the user: a beginning temperature, an ending temperature, and an increment value (all Fahrenheit.) b. Check for bad input: a temperature less than absolute zero and an ending temperature less than a beginning temperature. The program will send a message to STDERR if either condition is detected. c. Print a header showing: “Fahrenheit Celcius”. d. Under the header, print all the values from the beginning to the ending temperature in the increment provided. Use a looping mechanism. e. Ensure the user enters a floating point or decimal number. Do not accept whole numbers. Prompt for another input if such a condition is detected.

Replies are listed 'Best First'.
Re: CAN YOU FIGURE THIS OUT?
by jimbojones (Friar) on Mar 29, 2005 at 18:25 UTC
    Yes I can

Re: CAN YOU FIGURE THIS OUT?
by !1 (Hermit) on Mar 29, 2005 at 18:36 UTC
    What have you tried?
Re: CAN YOU FIGURE THIS OUT?
by ikegami (Patriarch) on Mar 29, 2005 at 18:38 UTC
    Indeed. Can you? What's the problem?
Re: CAN YOU FIGURE THIS OUT?
by jdporter (Paladin) on Mar 29, 2005 at 19:24 UTC
    I got all the way through college without cheating. Can you?
Re: CAN YOU FIGURE THIS OUT?
by Roy Johnson (Monsignor) on Mar 29, 2005 at 20:27 UTC
    Why is your header supposed to misspell "Celsius"?

    I congratulate you on having your inaugural post rocket to the top of the worst nodes of the day...and the week!

    Update: And month! (Except for some bug that's keeping it from showing your actual Rep there.) That's a trifecta!

    Update April 6: You have now topped the worst nodes of the year. Some of us are born to greatness, it seems.


    Caution: Contents may have been coded under pressure.

      They're dense enough to repost their homework assignment verbatim and you think they're going to be cognizant enough to spell correctly?

      Of course maybe it's because of the teacher's poor spelling they think they can get away with cribbing a solution off the 'net . . .

Re: CAN YOU FIGURE THIS OUT?
by Cody Pendant (Prior) on Mar 29, 2005 at 20:56 UTC
      http://boingboing.net/ says:
      It's an April Fool's Day hoax. Shannon sez, "the student doesn't exist, that school is a Christian school (that doesn't teach a course on Hinduism), and it's hosted on a comedy troupe's site that's trying to promote its new show, and their webmaster is spamming blogs with their story under a variety of fake names."

      Caution: Contents may have been coded under pressure.
        But then there's another update that possibly reverses the whole thing. Plus, it wasn't April Fool's day. And the college DOES have that course.


        ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
        =~y~b-v~a-z~s; print
Re: CAN YOU FIGURE THIS OUT?
by Errto (Vicar) on Mar 29, 2005 at 22:29 UTC

    This isn't even that well-written a question. What the hell does "floating point or decimal number" mean? What if the difference between the two endpoints is not an integer multiple of the increment?

    By the way, I don't actually recommend deleting the OP here (yes, I voted for it but I changed my mind). It's nice to have a blatant, unambiguous homework example to point to for reference, especially since we've had some disputed incidents of homework SOPWs recently.

      I know I'm new here, but I could I propose that we give it two weeks (just to make sure we allow for the possibility of spring break, and we assume that something this simplistic wouldn't be a multi-week assignment), and then see who can come up with the most creative solution, that meets all of the requirements, and yet would still fail spectacularly under realistic conditions. (and you've already suggested at least one failure scenario, but there's just sooo many more.)

        Sounds like a decent idea to me. I'll try to remember to come back and update my note.
        I choice for "meets all of the requirements, and yet would still fail spectacularly" would be falling into an infinite loop when the increment is 0.
Re: CAN YOU FIGURE THIS OUT?
by Popcorn Dave (Abbot) on Mar 29, 2005 at 23:42 UTC
    If you can't figure it out, have you thought about asking the person who wrote it in the first place? If you have an actual question on how to do this in Perl, then you're going to get a lot more constructive advice if you show what you've attempted and where you're getting stuck or where you don't understand what is going on.

    Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.
Re: CAN YOU FIGURE THIS OUT?
by inman (Curate) on Mar 30, 2005 at 07:14 UTC
    Why don't you forget Fahrenheit and Celsius and use the Kelvin scale instead? After all it does place absolute zero at zero and work upwards. You can use a conversion function to change the input to Kelvin and test for the start temp being greater than zero and less than the end temp.

    Using Cody Pendants post as inspiration. Implementing the Kelvin / Fahrenheit/Celsius conversion functions and better presentation is left as an exercise for the reader...

    #! /usr/bin/perl use strict; use warnings; kelvin (@ARGV); sub kelvin { my $start = $_[0]; my $end = $_[1]; my $inc = $_[2]; if (($start > 0) and ($start < $end)) { print "Fahrenheit Celcius\n"; my $loop = $start; while ($loop < $end) { print $loop, "\n"; $loop = $loop + $inc; } } else { die ("You entered bad arguments dumbass!"); } }

    Or just mess with his head...

    k2 (@ARGV); sub k2 {s{}{$_[0]-$_[2]}e;while( $_[0]>=0&&$_[0]<$_[1]&&s>([\d.]+)> $1<$_[1]?$1+$_[2]:''>e){print+qq +$_\n+};!$_||die ("Bad Params!")}
Re: CAN YOU FIGURE THIS OUT?
by xorl (Deacon) on Mar 30, 2005 at 08:45 UTC
      This guy didn't ask for help.

      He asked if we could figure out the posted problem. That's a distinction, yes, but an important one. The impression I got reading the OP was that the poster thought that "if I throw this up on this Perl site I just found, maybe someone will bite and give me the answer."

      Now, if the OP had said ... "I'm taking an intro programming class, the teacher is no good, here's my problem, and here's what I've tried so far ... " Even if what he'd tried was "here's the formula for converting F to C".

      I've gotten great responses here to problems that were killing me, and I thank the Monks for that. Asking for help is not the problem. Asking for the Monks to invest effort when the OP hasn't ... that is a problem.

      - jim

      There's nothing wrong with asking about homework-related issues on Perl Monks. There's nothing wrong with asking for help related to a project you're getting paid for (I've done it). There is something wrong with posting to Perl Monks expecting people to do your work for you. That's what we have here. Big difference.

        The original post does not say anything about the teacher. Being picky, we can not even know the student's character from it. Is he lazy? Maybe he/she is so confused by the problem not knowing even what precisely to ask (the teacher) to get more clarity?

        Anyway, there have been some very good answers with hints and links, like the step-by-step post. After all, it's a valuable answer if the OP does want to take some effort, no matter if he/she has been too lazy, not intelligent enough, or a bad teacher's student.

        By the way, the node's title is really silly.

      That's really unfair without seeing the teacher in action. If you don't understand an assignment, isn't it up to you to ask the teacher for clarification?

      ++ for your suggestions, and hopefully the OP will take those in to consideration.

      Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://443302]
Approved by xorl
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.