Explain parentheses in java, JAVA Programming

Assignment Help:

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;
}

}


Related Discussions:- Explain parentheses in java

Explain arithmetic promotion and binary operations, Explain Arithmetic Prom...

Explain Arithmetic Promotion and Binary Operations? An int divided through an int is an int, and a double divided by a double is a double, but what about an int divided by a do

Work is about 25% done but I am stuck, Modify the client server application...

Modify the client server application developed for phase 1 IP2 to be a Multithreaded Server (i.e. the server can handle concurrent requests from more than one client). Submit your

What is the comparable interface, What is the Comparable interface? Com...

What is the Comparable interface? Comparable interface is used to sort arrays and collections of objects using collections.sort() and java.utils. Objects of the class implement

Retrieving file records randomly, how to retrieve multiple records randomly...

how to retrieve multiple records randomly from a file and store it in another file

Using polymorphism to write a program to display digital clo, using polymor...

using polymorphism to write a program to display digital clock

Ask to do it, Ask question #Minig cbhdsjamkvfdsk mum 100 words accepted#

Ask question #Minig cbhdsjamkvfdsk mum 100 words accepted#

Program to insert item in tree, public class TreeTest {     public static v...

public class TreeTest {     public static void main(String args[])     {         Tree t = new Tree ();         System.out.println("Populating");         t.insertItem(1);         t

Multiple choices output and codes, codes and output on how to make multiple...

codes and output on how to make multiple choices quiz

Design a game in java, The game of Kala is played on a rectangular board: ...

The game of Kala is played on a rectangular board: In front of each player are six pits numbered 1 to 6 (called the 'side pits'). To the right of a player's side pits is a

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd