Home Answers Viewqa Java-Beginners temperature converting

 
 


madguy
temperature converting
2 Answer(s)      11 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
View Answers

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 :)









Related Pages:
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
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
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. ΓΆβ?¬Β
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 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 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 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 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 Anything to String
Java: Converting Anything to String Summary: Converting any data... control using some of the alternatives. Converting numbers to strings - See Converting Numbers to Strings There are many specialized issues with regard
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 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 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 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
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 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
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
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
java image converting to byte codes - Java Beginners
java image converting to byte codes  i want to convert an image to human unreadable format which is uploaded by client to server.How can i do
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
converting html to ppt,pptx - Java Beginners
converting html to ppt,pptx   Hi, i convert html to .doc format.But i want to convert the html to ppt,xml,pptx,docx,pdf.. Is there any possibility to solve this problem
converting html to ppt,pptx - Java Beginners
converting html to ppt,pptx   Hi, i convert html to .doc format.But i want to convert the html to ppt,xml,pptx,docx,pdf.. Is there any possibility to solve this problem
converting java class to java fx class
converting java class to java fx class   i am working on a java project which would convert text to speech and speech to text. i have developed.... but when i m converting the same file to javafx .. it is giving an error " speech
Converting a Filename to a URL
Converting a Filename to a URL       A file object is used to a give a filename. Creating the File object doesn't mean that a file exists. It may be that the does not exist. Suppose
Converting Numbers to Strings
Java: Converting Numbers to Strings Vanilla Java: Converting numbers to strings is easy. You can do almost everything with concatenation, but can get more... documented, they are a better second choice. Converting Anything to String
Converting the text files into bzip file.
Converting text  file into bzip file In this example, you will see, how to convert a text file into bzip file. In this example, we have printed 'I am a good programmer' along with converting a file into bzip file.  Opne the PHP
Issue in Converting .zip file to .jar file?
Issue in Converting .zip file to .jar file?  I have a folder called "printpdf.jar". I have changed the .jar to .zip and did some customizations. After which i had "zipped" it again and made as ".jar". Now the final file
converting pdf to ps in mutiple languages - Development process
converting pdf to ps in mutiple languages  hi deepak, i want to convert pdf in to ps. These PDF are in hindi format,these pdf are converted...). actually am converting the hindi pdf into hindi ps manuaaly, but i want
converting html to ppt,pptx - Java Beginners
converting html to ppt,pptx   Hi, i convert html to .doc format.But i want to convert the html to ppt,xml,pptx,docx,pdf.. Is there any possibility to solve this problem?  Hi Friend, We are providing you a code
converting Json data into rows of DTO in java
converting Json data into rows of DTO in java  I am using jqxgrid, and I am able to access the json data in JAVA controller. But now my requirement is to fetch every row of the grid and insert into the database. I have tried 'N
Conversion of temperature from kelvin to Celsius:
Conversion of temperature from kelvin to Celsius:         It is a very famous example and almost everyone of us have done this example once in any language
Java code for converting between .xls to .xlsx and vice versa - Java Beginners
Java code for converting between .xls to .xlsx and vice versa  I've a web application which allows clients to upload or download MS Excel sheets. I need a solution in Java from which i can upload in MS Excel 2003 and download
Converting PHP page with flash to JSP page without flash
Converting PHP page with flash to JSP page without flash  Hi, I have a page in php which has some flash content which represents the dynamic data carried by xml. Now I want to convert this php page to jsp and not use flash
converting From Hexadecimal to Decimal System - Java Interview Questions
converting From Hexadecimal to Decimal System  Write a program in Java user is required to enter a number system XVI and turn it into the decimal system, using StringBuffer  Check this link. http://www.roseindia.net
how to write the coding for converting the database data for example population into any type of graph using jsp and servlets?//
coding for converting the database data  how to write the coding for converting the database data for example population into any type of graph using jsp and servlets pls help me out how to write the coding for converting
convert excel file data into different locales while converting exclile file to csv file
convert excel file data into different locales while converting exclile file to csv file   can any one provide the code for how to convert excel file data into different locales while converting exclile file to csv file
Convert ArrayList to Array
In this section, you will learn about converting ArrayList to Array
Convert Array to ArrayList
In this section, you will learn about converting Array into ArrayList
Converting object to String
Converting object to String In this section you will learn to convert Object to String in java. It is sometimes necessary to convert object to String because you need to pass it to the method that accept String only. Object is a class
MySQL Converting Expression
MySQL Converting Expression       MySQL Convert function is used to convert the data from one type... Converting Expression'. To understand and grasp the example we use a query CAST
Converting an Array to a Collection
Converting an Array to a Collection       Here is the illustration for the conversion from... example gives you a brief introduction for converting an array to collection
Mysql converting expression
Mysql converting expression This example illustrates how to use the cast function and operator in mysql. In this example the Convert function is used to convert the data from one type to another type. The CONVERT() function is used
Converting Strings to Numbers
Java: Converting Strings to Numbers To convert a string value to a number (for example, to convert the String value in a text field to an int), use these methods. Assume the following declarations: String s; int i; long l; float

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.