2) Write a program that allows the user to convert a temperature given in degrees from either Celsius to Fahrenheit or Fahrenheit to Celsius. Use the following formulas: degrees Celsius = 5.0(degrees Fahrenheit - 32.0)/9.0 degrees Fahrenheit = 9.0(degrees Celsius / 5.0) + 32.0 Prompt the user to enter a temperature and either a C or c for Celsius or an F or f for Fahrenheit. Convert the temperature to Fahrenheit if Celsius is entered or to Celsius if Fahrenheit is entered. Display the result in a readable format. If anything other then C, C, F, or f is entered, print an error message and stop.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
I need help fixing my Java code on Branching and selecting methods provided here which is explained in the image provided:
import java.util.Scanner;
public class Branchingandselecting2 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args)
{
double degreesFahrenheit, degreesCelsius;
System.out.println("Type F for Fahrenheit or Type C for Celsius");
if keyboard == F:
System.out.println("Please enter temperature in degrees fahrenheit");
degreesFahrenheit = keyboard.nextDouble();
degreesCelsius = 5.0 *(degreesFahrenheit -32.0)/9.0;
System.out.println(degreesFahrenheit + " degrees Fahrenheit is" + degreesCelsius + "degrees Celsius");
else:
System.out.println("Please enter temperature in degrees Celsius");
degreesCelsius = keyboard.nextDouble();
degreesFahrenheit = 5.0 *(degreesCelsius -32.0)/9.0;
System.out.println(degreesCelsius + " degrees Celsius is" + degreesFahrenheit + "degrees Fahrenheit");
}
Step by step
Solved in 4 steps with 4 images