Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As part of our in class assignment, we were instructed to fix the solutions to our partner's code. The purpose of the code was to

As part of our in class assignment, we were instructed to fix the solutions to our partner's code. The purpose of the code was to convert the temperature based on the response of the user. The instructions to create the original code are below. The code that needs fixing is also below and has comments listed in bold that state the issues of the code made by my partner. I am truly confused and need help creating the code to fix the program. If anyone could help me with creating the code and pasting it into the original code, then paste the entire program with the fixed code into the solution. This is meant to be our study guide help for our upcoming test, but I too confused to even do this. Much love and help to all those who respond!

TEMP CONVERSION INSTRUCTIONS:

Write the IPO and pseudocode algorithm for a temperature conversion program that will allow the user to enter in an input temperature in one scale and then a target scale to convert to. The program would then convert to the target scale. EG If I were to enter 32.0 Fahrenheit as my input temperature and Celsius as my target scale the program would return 32.0 degrees Fahrenheit is equal to 0.00 degrees Celsius. Your program must support conversion to and from the following scales.

Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, Rmer

Your program must validate that the user has entered a proper scale

You will need the temperature conversion formulas from the following site.

https://en.wikipedia.org/wiki/Conversion_of_units_of_temperature

Your program must validate that the user has entered a proper scale for both the input scale and the target scale. Your program must also validate that the user has not entered a temperature that is below absolute zero. You can find the temperatures for absolute zero for each of the scales at the above web site.

Your program must allow the user to repeat this program as many times as they would like.

You will also need to show a paper check of the program working.

HINTS!!!!!

Convert from the input scale into an intermediate scale, such as the Kelvin scale, and then from that scale to the target scale. That will avoid converting directly from each scale into every other scale.

When validating for absolute zero, first convert to the intermediate scale. That will avoid the need of directly checking for absolute zero in every scale.

Example run:

Please enter a temperature:

-333.3

Please enter your temperature scale:

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

myown

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

Celsius

That temperature is below absolute zero, and therefore is invalid.

You need to enter a temperature that is greater than or equal to absolute zero.

Please enter a temperature:

33.0

Please enter your temperature scale:

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

myown

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

Fahrenheit

Please enter your target temperature scale:

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

myown

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

Celsius

You entered 33.0 degrees Fahrenheit, which is equal to 0.56 degrees Celsius.

Would you like to enter another temperature?

Please enter Y for yes or N for No.

b

Please enter Y for yes or N for No.

Y

Please enter a temperature:

33.0

Please enter your temperature scale:

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

Celsius

Please enter your target temperature scale:

Please enter Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer

Fahrenheit

You entered 33.0 degrees Celsius, which is equal to 91.4 degrees Fahrenheit.

Would you like to enter another temperature?

Please enter Y for yes or N for No.

N

Good-Bye!!

---------------

PARTNERS CODE THAT NEEDS FIXING

START

DECLARE REAL temp

DECLARE STRING initialScale

REPEAT

DISPLAY Please enter a temperature greater or equal to than 0.00 Kelvin, 0.00 C, -0.00 F, 0.00 Rankine, 0.00 Delisle, 0.00 Newton, 0.00 Reaumur, and 0.00 Romer//Only Kelvin is 0.0 at absolute zero. The value is different for other scales. It is -273.15 for Celsius. -2

GET temp

UNTIL temp>= 0.00 Kelvin, OR temp >= 0.00 C, OR temp >= 0.00 F, OR temp >= 0.00 Rankine, OR temp >= 0.00Delisle, OR temp >= -0.00 Newton, OR temp >= -0.0014 Reaumur, OR temp >= 0.00 Romer//You cannot compare a number and a STRING in the same compare. Also, the user did not enter a STRING. You just got the REAL value from the user and stored it into temp. -2

tempConverter()//This is not a proper module call. -2

You do not allow the user to repeat the program. -10

STOP

BEGIN tempConverter()//This is not a proper module header. -2

DECLARE STRING targetScale

DECLARE INT convTemp

REPEAT

DISPLAY Please enter Kelvin, Fahrenheit, Celsius, Kelvin, Rankine, Delisle, Newton, Raumur, or Rmer to convert your temperature.

GET targetScale

UNTIL targetScale = Fahrenheit, OR targetScale = Celsius, OR targetScale = Kelvin, OR targetScale = Rankine, OR targetScale = Delisle, OR targetScale = Newton, OR targetScale = Raumur, OR targetScale = Rmer

IF initialScale = Celsius THEN//Where does initialScale come from? It is in the main program and not visible in this module. You also did not ask the user for it as input. -5

IF targetScale = Fahrenheit THEN

convTemp = [temp] 9?5 + 32

ELSE

IF targetScale = Kelvin THEN

convTemp = [temp] + 273.15

ELSE

CAN VIEW THE ENTIRE CODE IN IMAGES BY CLICKING THE IMGUR LINK. I didnt want to post the entire code as text because chegg kept regulating my text length and wouldnt post the question.

https://imgur.com/a/JXTfO

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions