explain parentheses in java sometimes the default


Explain Parentheses in Java ?

Sometimes the default sequence of evaluation isn't what you want. For example, the formula to change a Fahrenheit temperature to a Celsius temperature is C = (5/9) (F - 32) whereas C is degrees Celsius and F is degrees Fahrenheit. You must subtract 32 from the Fahrenheit temperature before you multiply by 5/9, not after. You can use parentheses to adjust the frequently much as they are used in the above formula. The further program prints a table presentation the conversions from Fahrenheit and Celsius between zero and three hundred degrees Fahrenheit every twenty degrees.
// Print a Fahrenheit to Celsius table

class FahrToCelsius {

public static void main (String args[]) {

// lower limit of temperature table
double lower = 0.0;

// upper limit of temperature table
double upper = 300.0;

// step size
double step = 20.0;

double fahr = lower;
while (fahr <= upper) {
double celsius = (5.0 / 9.0) * (fahr-32.0);
System.out.println(fahr + " " + celsius);
fahr = fahr + step;
}

}

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: explain parentheses in java sometimes the default
Reference No:- TGS0284336

Expected delivery within 24 Hours