temperature converting
2 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners

Write a program that makes use of a class called Degrees that implements the following doublemethods as per the UML class

```    Method celsius returns the Celsius equivalent of a given Fahrenheit temperature
Method fahrenheit returns the Fahrenheit equivalent of a given Celsius temperature
Method displayTable should use the above methods to prints charts showing:

The Fahrenheit equivalents of all Celsius temperatures from 0 to 100 degrees in 4 degree intervals
The Celsius equivalents of all Fahrenheit temperatures from 32 to 212 degrees in 10 degree intervals
Both columns in each chart should be printed to one decimal place
Print the charts in a neat tabular format that minimizes the number of lines of output while remaining readable
```

June 19, 2012 at 1:20 PM

Here is an example of Temperature Conversion where we have converted Celcius to Fahrenheit and vice versa. For this, we have create three functions celcius(), fahrenheit() and display table which display the conveted values in the form of chart.

```import java.util.*;
import java.text.*;

class Degrees
{
public static double fahrenheit(int temp) {
return (1.8 * temp) + 32;
}

public static double celsius(int temp) {
return (temp - 32) / 1.8;
}
public static void displayTable(){
DecimalFormat df=new DecimalFormat("##.#");
System.out.println("Celcius (C)   Fahrenheit (F)");
for(int i=0;i<=100;i+=4){
System.out.println(i+"\t    |     "+df.format(fahrenheit(i)));
}
System.out.println("Fahrenheit (F)   Celcius (C) ");
for(int i=32;i<=212;i+=10){
System.out.println(i+"\t    |     "+df.format(celsius(i)));
}
}

public static void main(String[] args)
{
displayTable();
}
}
```

July 1, 2012 at 4:59 AM

thanks :)

temperature converting
temperature converting   Write a program that makes use of a class... temperature Method fahrenheit returns the Fahrenheit equivalent of a given Celsius temperature Method displayTable should use the above methods to prints
Help with Temperature program
Help with Temperature program  I need help to write a GUI program to calculate the temperature. and here is the format Application that converts temperature between 3 different scales: Fahrenheit, Celsius and Kelvin. ΓΆβ?¬Β
Temperature Converter in SWT
are created for converting the temperature. A button is created to perform an action... Temperature Converter in SWT       This example illustrates you how to convert temperature from
Convert Temperature
Convert Temperature       This section illustrates you how to convert the temperature from Fahrenheit to Celsius. To convert the temperature, we have created two
C Temperature Converter
C Temperature Converter       Here we are going to illustrates you how to convert temperature... the user to enter the temperature in celsius. The scanf() function gets the entered
Java Temperature Converter
Java Temperature Converter In this tutorial, you will learn how to convert temperature from Celsius to Fahrenheit and vice versa. Here is an example where we have created three functions celcius(), fahrenheit() and display table
Converting ISO8601-compliant String to java.util.Date
Converting ISO8601-compliant String to java.util.Date  Converting ISO8601-compliant String to java.util.Date
converting string to double in java
converting string to double in java  Please post an example to converting string to double in java. Thanks!   Convert String to Double Tutorial
Converting PDF in to XML
Converting PDF in to XML  I have to convert PDF into XMl without any loss in text. Please suggest sth good
converting field to text sql
converting field to text sql  I wanted to convert the field to TEXT in SQL.. is it possible?   SQL - Converting the field to TEXT works SELECT CONVERT(TEXT,fld_name) FROM TABLE_NAME   SQL - Converting
Converting a NSString into NSDate
Converting a NSString into NSDate  hello. How can I create a NSDate object out of it and then get different components like day, month, date, year from it. I have date string: Tuesday, October 19, 2010
Converting XML to string
Converting XML to string  Hi Friends, I had an requirement in which a java program receives an xml messages from external web application such as (jsp, php) and then it converts the received xml message into a string. could
Converting string to Int - JDBC
Converting string to Int  String nrate=request.getParameter("t3"); i want convert this nrate to integer to make calculations on it... so what should i do??? where t3 is a text area name and i am fetching...  Hi
converting decimal to base 32
converting decimal to base 32  procedure for converting decimal to base 32   CREATE PROCEDURE RTCONVERSION ( @valueToConvert int, @convertedValue varchar(20) out ) AS declare @counter int; declare @num int; declare @x
Converting NSURL to NSString creating a problem
Converting NSURL to NSString creating a problem  Hi , In my iPad/iPhone universal application, we are trying to covert theNSURL to NSString which cause the application crash. Does any one have idea about converting NSURL
Converting NSURL to NSString creating a problem
Converting NSURL to NSString creating a problem  Hi , In my iPad/iPhone universal application, we are trying to covert theNSURL to NSString which cause the application crash. Does any one have idea about converting NSURL
Converting Text Files into Bzip File
Converting Text Files into Bzip File  Hi, I am facing the problem during run the program, when converting text files into Bzip file. Please guide me how do i convert the text file into bzip file in PHP. I will welcome, if anyone
Converting jsp variable to java variable
Converting jsp variable to java variable  Hi how to convert java script variable to java variable on same jsp page
converting html file into pdf - Struts
converting html file into pdf  i want to convert html file into pdf file using java code please help me
converting image to byte[] - Java Beginners
converting image to byte[]  Dear Sir Can you please tell me a solution for converting a java.awt.Image to byte[] eg: java.awt.Image... for converting } Please give me a solution Thanks in Advance. Rahul
converting one file format to another
converting one file format to another  Hi ser I need a code to export data from data grid to PDF and XL format plz help me out
Converting HTML to image - Java Beginners
Converting HTML to image   Is it possible to convert html to image with java code ?   Hi friend, Please give the problem in details for complete solution. For read more information : http
ffmpeg converting file mp4 to mov
ffmpeg converting file mp4 to mov  Hi, How to convert the mp4 file into mov file? Thanks   Hi, You should install ffmpeg on your computer and then use the following command to convert mp4 file into mov file
Converting HTML to XML - Java Beginners
Converting HTML to XML  Hi, I am generating an HTML file (JSP from a Java Struts App.) I need to figure out a way to create an XML file from that HTML document. If you can refer me to some Java Code, that would
losing precision converting from java BigDecimal to double
losing precision converting from java BigDecimal to double  losing precision converting from java BigDecimal to double
converting an xml file in relational database objects
converting an xml file in relational database objects  converting an xml file in relational database objects
xml Converting to java using JDOM
xml Converting to java using JDOM  Hello , I am new to java and JDom so i make a Xml file and i need help to read it from java using objects , my idea is i have school has a class,class has a 3 students ,student has a address
Javascript Question about converting Celcius to Fahrenheit
Javascript Question about converting Celcius to Fahrenheit  How to create a program to ask the user to enter a temperature in degrees celcius it convert it to fahrenheit using the following formula: f = (c*9/5)+32
Converting a String to Integer in Java
Converting a String to Integer in Java In this video tutorial I will show you.... There are two methods of converting the String into integer value. One method... is example code for converting a string to Integer: String strNoOfItems = "
I converting binary to decimal and vice versa
I converting binary to decimal and vice versa  can i ask for the codes in converting binary to decimal and decimal to binary to be run in one program with repeat.. pls. help me! i badly need the codes by monday!! pls
converting binary text to ascii readable text
converting binary text to ascii readable text  is there a way to read binary txt file and write them as ascii readable text files
Tutorials