Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This a JAVA Programming Lab assignment. create a method that will be called to calculate Fahrenheit temperature using a user entered celsius value. Create a

This a JAVA Programming Lab assignment.

create a method that will be called to calculate Fahrenheit temperature using a user entered celsius value.

Create a class named CalculateFahrenheit. The class shall have two methods: main and celsiusToFahrenheit. Both are static.

Create a celsiusToFahrenheit method.

The celciusToFahrenheit method accepts a double input of celsius value and returns a double value of the equivalent fahrenheit temperature.

Its header is static double celsiusToFahreheit(double c)

The method assumes that the input c value is greater than -273 and less than 1000. Therefore no action is necessary, other than a comment, to insure the input is within range.

The conversion to Fahrenheit temperature is f = (9/5) c +32

Create a main method

In main the program shall prompt a user to enter a Celsius temperature.

If the input is between -273 and 1000, main shall call the celciusToFahrenheit method passing the celcius input value. However, if the user input is not within the allowable range, a message shall be output informing the user the input is bad and the celsiusToFahrenheit method shall not be called.

When the celsiusToFahrenheit method is called, main shall display the return value and exit.

Test the program using at least two test cases. One where the celcius value is between -273 and 1000 and one where the celsius value is outside that range.

New concepts:

A method has a specific structure. The input parameter parenthesis are always present. If there are no inputs, it is empty. Otherwise the input data type and local name is included. There can be any number of input parameters separated by comas. The return data type must be specified. When there is no return, the return data type is void.

A method must explicitly return a value when the return data type is anything except void using the return keyword.

Input parameters are passed by value.

The scope of an input parameter is local to the method. It is an error (double declaration) to declare the input parameter inside the method.

A method is called, from a method inside its class by stating the method name and input parameters (arguments).

Question:

Can the method celsiusToFahenheit be called from a System.out.println Statement?

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

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions