Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fahrenheit/Celsius Temperature Converter Create a Visual Basic pseudocode in Not

ID: 3705766 • Letter: F

Question

Fahrenheit/Celsius Temperature Converter

Create a Visual Basic pseudocode in Notepad ++ that asks the user whether they want to convert their temperature from Fahrenheit to Celsius or Celsius to Fahrenheit (or 0 to quit). Be sure to get the temperature from the user that needs to be converted. Calculate the conversion the user requested and display the original temperature and its unit (Fahrenheit or Celsius) and the conversion plus its unit.

The program should loop until the user is ready to quit.

Explanation / Answer

START

DECLARE as Double Fahrenheit, Celsius, choice

DO

DISPLAY "Please enter one of the following choices:"

DISPLAY "1. Convert temperature in Celsius scale to Fahrenheit scale."

DISPLAY "2. Convert temperature in Fahrenheit scale to Celsius scale."

DISPLAY "0. Quit"

DISPLAY "Enter your choice"

INPUT choice

CASE choice

CASE choice == 1

DISPLAY "Enter Temperature in Celsius scale to change into Fahrenheit scale"

INPUT Celcius

SET Fahrenheit = 1.8 * Celsius + 32

DISPLAY "You entered " & Celcius & "degree Celcius and its equivalent is " & Fahrenheit & " degree Fahrenheit."

CASE choice == 2

DISPLAY "Enter Temperature in Fahrenheit scale to change into Celsius scale"

INPUT Fahrenheit

SET Celcius = 0.5556 * (Fahrenheit - 32)

DISPLAY "You entered " & Fahrenheit & "degree Fahrenheit and its equivalent is " & Celcius & " degree Celcius."

CASE choice == 0

DISPLAY "Exiting"

DEFAULT

DISPLAY "Invalid Choice Please choose between 0 to 2. "

END CASE

WHILE(choice != 0)

STOP

The Case statement is equivalent to multiple IF THEN ELSE ladder. It can only be used when the comparison that is been done is against a constant that is if variable's value exactly matches the provided constant or not. In Visual Basic this statement is implemented using SELECT CASE. For example, you have a variable 'var' which you are comparing against a numeric constants 1, 10 and 100.then you have to implement like this

Select Case var

Case 1

<required statements>

Case 10

<required statements>

Case 10

<required statements>

Case 10

<required statements>

Case 100

<requied statments>

Case Else

<default Statement, the statement you wanna show if none of the expected cases matches>

End Select

Happy coding :-)