Hello everyone:

I am new here. I am taking an entry-level programming class at an online school. We are in our 5th week of pseudocode and learning to use loops and sentininels. I have just completed and individual assignment and was wondering if anyone would be nice enough to look at it and see if I left anything out. The assignment is to write a code that allows the user to enter a series of temperatures in degrees Celsius (C) terminated by the input of –999, using the conversion formula of F = 9 * C/ 5 + 32. For each one, find the corresponding temperature in degrees Fahrenheit (F).

This is what I came up with using the supplied template...

Declare C As Float
Declare F As Float
Declare Temperature As Float
Write “Temperature Conversion Program”
Write “This program will convert a temperature, entered in”
Write “degrees Celsius, to degrees Fahrenheit.”
    Write “enter a temperature  number or press -999 to quit”
    Input Temperature
    While Temperature != -999
        Set F = 9 * C/ 5 + 32
    Write “The Temparture in Fahrenheit is”
End While

Recommended Answers

All 3 Replies

Your loop is incorrectly placed. It should wrap all of the prompts, input request, computation, and output for each temperature:

Set Temperature = 0
While Temperature != -999
    Write “enter a temperature number or press -999 to quit”
    Input Temperature
    Set F = 9 * Temperature / 5 + 32
    Write “The Temparture in Fahrenheit is”, F
End While

As deceptikon said. Also, make sure that you scope your expressions properly. IE, instead of Set F = 9 * C/ 5 + 32, use Set F = 9 * (C/5) + 32 - that will make sure that your mathematical expressions are properly evaluated.

Thanks a lot guys. You are awesome and I owe a virtual beer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.