[SOLVED] CS1331 Homework 02 Temperature Converter

$25

File Name: CS1331_Homework_02_Temperature_Converter.zip
File Size: 376.8 KB

SKU: [Solved] CS1331-Homework 02 – Temperature Converter Category: Tag:
5/5 - (1 vote)
hw02_Temperature_Converter

Problem Description

The company that has hired you has a problem. Half of their thermostats display in degrees Celsius and the other half display in degrees Fahrenheit. All of their thermostats display in integers. Unfortunately there is no way to change the unit of a given thermometer. To remedy this problem your company has asked you to write a simple Java program that will allow your co-workers to easily convert between the two units. Your company has provided you with a Java class Converter.java, so all you will have to do is fill in the provided methods.

Solution Description

For this assignment you have been provided Converter.java. This class has several methods where only a method header has been written. To complete this assignment you should correctly fill in the body of each method as specified here and in the provided java file.

The methods you will have to fill in are listed here.

fahrenheitToCelsius(int temp)

This method takes in a temperature in Fahrenheit and should return that temperature in Celsius as a double.

celsiusToFahrenheit(int temp)

This method takes in a temperature in Celsius and should return that temperature in Fahrenheit as a double.

printFahrenheitConversionTable(int lower, int upper)

This method prints out a table of Fahrenheit temperatures from the specified lower bound (inclusive) to the specified upper bound (inclusive) and that temperature converted to Celsius. Round to three decimal places.

Ex) if we ran printFahrenheitConversionTable(32, 33) we should get whats printed below. Please make sure to use this format exactly or you will not get credit.

Fahrenheit: 32 -> Celsius: 0.000

Fahrenheit: 33 -> Celsius: 0.556

Note: This method should be completed using a FOR loop. You MAY NOT use a while loop anywhere in this method. Doing so will yield no credit

printCelsiusConversionTable(int lower, int upper)

This method prints out a table of Celsius temperatures from the specified lower bound (inclusive) to the specified upper bound (inclusive) and that temperature converted to Fahrenheit. Round to three decimal places.

Ex) if we ran printCelsiusConversionTable(32, 33) we should get whats printed below. Please make sure to use this format exactly or you will not get credit.

Celsius: 32 -> Fahrenheit: 89.600

Celsius: 33 -> Fahrenheit: 91.400

Note: This method should be completed using a WHILE loop. You MAY NOT use a for loop anywhere in this method. Doing so will yield no credit.

celsiusWarmer(int celsius, int fahrenheit)

This method takes in two temperatures, the first in Celsius and the second in Fahrenheit, it should return true if the first temperature is warmer than the second.

Note: Do NOT use a ternary expression. Doing so will yield no credit.

fahrenheitWarmer(int fahrenheit, int celsius)

This method takes in two temperatures, the first in Fahrenheit and the second in Celsius, it should return true if the first temperature is warmer than the second.

Note: you should use a ternary expression to complete this method. Do NOT use an if statement. Doing so will yield no credit.

Testing your code

If you want to test out your own code before submitting, weve provided some sample cases in the main method. If you run java Converter after compiling your code, this will be the output from the provided cases.

fahrenheitToCelsius: 1.1111111111111112 celsiusToFahrenheit: 39.2 printFahrenheitConversionTable: Fahrenheit: 32 -> Celsius: 0.000

Fahrenheit: 33 -> Celsius: 0.556

Fahrenheit: 34 -> Celsius: 1.111

Fahrenheit: 35 -> Celsius: 1.667

Feel free to create your own tests in the main method! Try to write tests for the remaining methods in the file!

Rubric

  • [15] celsisusToFahrenheit
  • [15] fahrenheitToCelsius
  • [20] printFahrenheitConversionTable
  • [20] printCelsiusConversionTable
  • [15] fahrenheitWarmer
  • [15] celsiusWarmer

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS1331 Homework 02 Temperature Converter
$25