Temperature values between different scales

  1. Demonstrate programming fundamentals – decisions, loops, arithmetic operations, arrays, use of objects, constructing and using methods, parameter passing, etc.
  2. Demonstrate console I/0
  3. Demonstrate text file input
  4. Demonstrate ability to follow a program specification


  1. Produce a program that converts temperature values between 4 different scales -Fahrenheit, Celsius, Kelvin, Rankine.
  2. A starting program (TemperatureConversion.java) with required methods to complete is provided below. No credit is given if this starting file is not used. and must be used to receive credit


  1. Produce the four methods defined in the provided starting programTemperatureConversion.java:

public double fahrenheitToOther (double value, char scale)

public double celsiusToOther (double value, char scale)

public double kelvinToOther (double value, char scale)

(double value, char scale)

Each of these takes two parameters, a double value and a target scale. The scale values will be one of these characters: ‘F’, ‘C’, ‘K’, ‘R’. For example, fahrenheitToOther assumes that the given value is in Fahrenheit and converts that value to the new scale and returns the converted value.

For example, the method below shows celsiusToOther in use.An original value and a new scale are passed to it.As the name of the method celsiusToOther implies, the original value is of scale Celsius.The celsiusToOther method must contain the code to convert the given value to the given scale.

public double doConversion (double originalValue, char originalScale, char newScale)


double newValue = 0.0;

if (OriginalScale == CELSIUS)

newValue = celsiusToOther(originalValue, newScale);

return newValue;


Do not change the signatures of any of the methods. You are required to use the char type to assess the problem. Use defined constants where needed.

  1. Complete the doConversion method that is defined in TemperatureConversion.java. Notice that it only allows for conversion from Celsius. Decisions and calls for the other conversion methods must be added to use the other three xxxToOther methods. Remember that to use a class, an object of that class type must be created.

Conversion factors for translating between the different scales are readily available on various sites on the internet. Use defined constants whenever possible stylistically.

3: Add console input

Modify the main program in TemperatureConversion.java to allow for user input of single conversions.Loop and until a user indicates that he/she is finished. Your program should prompt for a value, starting scale, and target scale then perform the conversion and output the result.

  • Make sure that your program works for both upper and .
  • Make sure that you can recover from user input of an incorrect scale. Your program should continue and not terminate with incorrect alpha characters.
  • Check for negative Kelvin and Rankine input temperatures. Your program should continue and not terminate with the input of a negative Rankine or Kelvin temperature.
  • Be sure to test at least three of each conversion.See the test data spreadsheet included on canvas.

4: Add File input

Prompt for the name of a file that contains a series of conversions and perform those conversions. The file should be a text file with the following format:

There is one set of conversion data per line of the file.

Each line of the file contains an original value, an original scale, and the target scale, for example,

23 F C

18.5 K R

You will use the text file temptest.txt, which I created in notepad.The file is in canvas.Note that in case of an error in the file a zero is displayed for the conversion along with a message. A complete run of the program output is at the end of this document. You may want to test your program with no error data and then test it with the error data to make sure you meet the specifications.

  1. Use some Error Handling

Your program should handle errors with a console message and return 0.0 when any conversion is not possible. For example, if a user enters ‘V’ instead of ‘C’, aconsoleerror message is displayed and the conversion method returns 0.0

Sample Program Run

Here is the sample run of a program that and file input.User input is in green.

Enter a number to choose one of the following options:

  1. Convert temperatures one at a time.
  2. Convert temperature from a list of value in a .txt file.
  3. End the program


You selected 1

Enter temperature:25.5

Enter scale (F, C, K, R):


Enter scale to convert to (F, C, K, R):


25.50 Cis77.90 F

Would you like to doanother conversion? (y/n):


Enter temperature:100

Enter scale (F, C, K, R):


Enter scale to convert to (F, C, K, R):


100.00 Cis373.15 K

Would you like to doanother conversion? (y/n):


Enter a number to choose one of the following options:

  1. Convert temperatures one at a time.
  2. Convert temperature from a list of value in a .txt file.
  3. End the program


You selected 2

Enter name of inputfile


60.00 Fis288.71 K

70.00 Fis529.67 R

30.00 Fis-1.11 C

50.50 Cis122.90 F

60.50 Cis333.65 K

70.50 Cis618.57 R

20.00 Kis-423.67 F

30.00 Kis-243.15 C

40.00 Kis72.00 R

20.50 Ris480.17 F

30.50 Ris-256.21 C

40.50 Ris22.50 K

error invalid original scale specifiedD

0.00 Dis0.00 F

0.00 Cis32.00 F

error invalid original scale specifiedA

25.30 Ais0.00 K

error invalid conversion scale specifiedA

27.00 Fis0.00 A

54.00 Fis12.22 C

20.00 Kis-253.15 C

End of file processing.

Enter a number to choose one of the following options:

  1. Convert temperatures one at a time.
  2. Convert temperature from a list of value in a .txt file.
  3. End the program


You selected 3


Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
Need assignment help? You can contact our live agent via WhatsApp using +1 718 717 2861

Feel free to ask questions, clarifications, or discounts available when placing an order.
  +1 718 717 2861           + 44 161 818 7126           [email protected]
  +1 718 717 2861         [email protected]