Take Input Of Temperature In Fahrenheit And Convert It To Celsius And Kelvin

Oct 28, 2014

I’m trying to write a program in Java that will take the input of a temperature in Fahrenheit and convert it to Celsius and Kelvin. This is what I have so far but when I run the program on Eclipse it says the temp. in Celsius is infinity and the same for kelvin. Why is it not preforming the operation and spiting out the correct numbers?

import java.util.Scanner;
public class Temperature {
public static void main(String[] args) {
// This program converts temperatures from Fahrenheit to Celsius to Kelvin.
double temperature1;// operands
double temperature2;
double temperature3;

[Code] ....

View Replies


ADVERTISEMENT

Temperature Conversion Celsius To Fahrenheit

Jun 16, 2014

I have followed the instructions carefully but the conversion values are not correct.

Write a program that displays a table of the Celsius temperatures 0 through 20 and their Fahrenheit equivalents. The formula for converting a temperature from Celsius to Fahrenheit is
F - | C + 32
where ¥ is the Fahrenheit temperature and C is the Celsius temperature. Your program must use a loop to display the table.

Code

public class TempConversion
{
public static void main(String[] args) {
for(double i = 0; i <= 20.0; i++) {

[Code] ....

View Replies View Related

For Loop - Convert Fahrenheit To Kelvin

Jul 7, 2014

I was asked to work on building a program that can convert Fahrenheit to kelvin. Need to create a for loop that spits out the value of kelvin for every degree increase from 32 degrees Fahrenheit to 100 degrees Fahrenheit.

View Replies View Related

Program Converting Fahrenheit To Celsius Using For Loop (will Not Convert)

Sep 13, 2014

I am trying to write a program converting Fahrenheit to Celsius using a for loop. I get it to run and Fahrenheit goes to a hundred. My issue is that the Celsius just says 100 down the column and is not converting. I have tried messing with it, and can not figure what is wrong with it.

import java.util.Scanner;
public class Controlstatement {
public static void main(String[] args) {
double F = 1.0;
double Celcius = 100;
System.out.printf("%s%20s", "Farenheit", "Celcius" );
for (int Farenheit = 0; Farenheit <= 100; Farenheit++) {
F = Celcius * (Farenheit - 32 * 5.0/9.0);
System.out.printf("%4d%,20.2f", Farenheit, Celcius);
}
}
}

The output looks like this all the way to 100:

Farenheit Celcius
0 100.00
1 100.00
2 100.00
3 100.00

View Replies View Related

Temp Conversion Fahrenheit To Kelvin

Oct 17, 2014

Every time I input a number for fahrenheit, I always get 273.15. Everything compiles, the only problem is that run-time error. I need getting fahrenheit to exactly change to kelvin.

//my class
public class TempConversion
{
private double fahrenheit;
public TempConversion() {
fahrenheit = 0;

[Code] .....

View Replies View Related

Celsius To Fahrenheit Java GUI

Aug 4, 2014

Write a CiUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then sec the equivalent Flhnfflhelt temperature. Use the following formula to make the conversion: F - - y C + 32..F is the Fahrenheit temperature and C is the Celsius temperature.

Now the program runs (In Jgrasp) But when I Enter a number in the fahrenheit box and hit "COnvert' NOTHING happens. I went over my code and I can't find what seems to be the problem...I tried changing

ActionListener Listener = new ConvertListener();
convertBtn.addActionListener(ConvertListener); <----- I tried changing ConvertListener to just Listener but it gives me more problems
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

[code]....

View Replies View Related

Converting Fahrenheit To Celsius

Oct 1, 2014

I'm new to coding and we have an assignment for class to convert fahrenheit to celsius so far this is what i have:

import java.util.Scanner;
public class Lab5 {
public static void main(String[] args) {
//variable dec
Scanner scan = new Scanner(System.in);
double input;

[code]...

This is what he wants us to do "Write a method name celsius that accepts a Fahrenheit temperature as an argument. The method should return the temperature, converted to Celsius. Demonstrate the method by asking the user a temperature value to convert. Then below the result, call a loop that displays a table of the Fahrenheit temperatures 0 through 20 and their Celsius equivalents."

View Replies View Related

GUI Converter Button - Fahrenheit To Celsius

Nov 13, 2014

I am new to java and I am trying to learn a little about GUI. I found this problem of creating a converter for temp from farenheit to celcius. I have everything working, except for when I hit the converter button... it does not convert.

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

[Code] .....

View Replies View Related

Fahrenheit To Celsius Converter - Output Box

Sep 23, 2014

The assignment reads: Develop a Java program (F2C.java) for converting a temperature from the Fahrenheit to the Celsius scale. The program will read the temperature graphically using an input dialog box

(JOptionPane.showInputDialog) and will show also the result graphically on a message dialog box (JOptionPane.showMessageDialog).

I can get my input box to show, but I am unable to get to the output box

What I have came up with:

import javax.swing.JOptionPane;
public class F2C {
public static void main(String[] args) {
// Enter Farenheit
String Fahrenheit = JOptionPane.showInputDialog(

[Code] .....

View Replies View Related

Initial Template Which Converts Fahrenheit To Celsius

Oct 20, 2014

I am new to Java, programming, and intelliJ. I am trying to make a BMI Calculator using this code as my initial template which converts Fahrenheit to Celsius.

import javax.swing.JFrame;
public class Fahrenheit
{
//-----------------------------------------------------------------
// Creates and displays the temperature converter GUI.
//-----------------------------------------------------------------

[code]....

I created a local field within BMIButtonListener for weight, height, resultLabel, and was able to compile but it did not calculate and listed exceptions.

View Replies View Related

Store Celsius And Fahrenheit Values Equal To One Another Using Loop

Sep 29, 2014

Write java program using table that stores celsius and farenheit values that are equal to one another using a loop. use C 0-20 and convert to farenheit.

I have to use doubles for Celsius and Fahrenheit and in the formula. I get a runtime error with the following displayed:

I will display a table of temperatures in their Celsius and Farenheit equivalents.

celsiusfarenheit

import java.util.*;
import java.lang.*;
import java.io.*;
class TemperatureConversion {
public static void main (String[] args) throws java.lang.Exception {
double celsius;// Temperature in degrees Celsius minimum
double farenheit;// Temperature in degrees Fahrenheit

[Code] ....

View Replies View Related

Confirming Conversion To Compute - Calculate Fahrenheit Or Celsius Value

Sep 28, 2014

<import javax.swing.JOptionPane;
public class TempCalc {

public static void main(String[] args) {

//Confirming which conversion to compute.
String FarOrCel = (JOptionPane.showInputDialog("Would you like to calculate a Farenheit value or a Celsius value? (Enter Farenheit or Celsius)");

[Code] ....

So I've been trying to come up with a Farenheit to Celsius converter and back. However, whenever I run the program in JCreator it never recognizes the string "Farenheit". Even if I put that exact thing (I copy/pasted from the if (FarOrCel == "Farenheit")) it keeps asking me for a Celsius value.

[quote name='INNOCENTREAPER##!' date='28 September 2014 - 07:40 PM' timestamp='1411958437' post='2057072']

<import javax.swing.JOptionPane;
public class TempCalc {
public static void main(String[] args) {

//Confirming which conversion to compute.
String FarOrCel = JOptionPane.showInputDialog("Would you like to calculate a Farenheit value or a Celsius value? (Enter Farenheit or Celsius)";

[Code] ....

View Replies View Related

Write A Program To Print Out Fahrenheit-Celsius Conversion Table?

Oct 14, 2014

This is my program

import java.util.Scanner;
import java.text.DecimalFormat;
public class Lab6 {
public static void main(String[] args) {
int F;
double C = 0;

[Code] ......

output

0 1 2 3 4 5 6 7 8 9
0 degree Fahrenheit equal to :-00.00 degree Celsius
1 degree Fahrenheit equal to :-00.00 degree Celsius
2 degree Fahrenheit equal to :-00.00 degree Celsius
3 degree Fahrenheit equal to :-00.00 degree Celsius
4 degree Fahrenheit equal to :-00.00 degree Celsius
5 degree Fahrenheit equal to :-00.00 degree Celsius
6 degree Fahrenheit equal to :-00.00 degree Celsius
7 degree Fahrenheit equal to :-00.00 degree Celsius
8 degree Fahrenheit equal to :-00.00 degree Celsius
9 degree Fahrenheit equal to :-00.00 degree Celsius

I don't know why the program is not calculating the C degree ?

View Replies View Related

Simple Program In Java (Eclipse) That Converts Fahrenheit To Celsius

Apr 10, 2014

I've made a simple program in Java (Eclipse) that converts Fahrenheit to Celsius.The class is:

Java Code: package ehu.student;
public class ConversorTemperaturas {
/*--------------------------------------------------------------*/
/*Clase que dado una temperatura en Fahrenheit la canvierte en C*/
/*--------------------------------------------------------------*/
public float farenheit2celsius (float d){
float celsius, aux;

[code]...

When I write t.farenheit2celsius(25.6), appears the following error: "The method farenheit2celsisus(float) in the type ConversorTemperaturas is not applicable for the arguments (double)"If i change in the class the type float for double there is not problem. Why can't i use the type float?

View Replies View Related

Converting Celsius To Fahrenheit And Vice Versa Using Methods And Loop

Oct 13, 2014

I need to do a conversion of Celsius to Fahrenheit and viceversa using methods and a for loop. The methods are public static double celsiustoFahrenheit (double celsius) and public static double Fahrenheittocelsius (double fahrenheit). It gives me weird numbers and i have to have some format that you can see attached ....

package temperatureconverter;
import java.util.Scanner;
public class TemperatureConverter {
public static void main(String[] args) {
Scanner corvette = new Scanner(System.in);
System.out.printf("%12s%12s","Celsius","Fahrenheit");

[Code] .....

Attached image(s)

View Replies View Related

Create A Java File That Will Print Out Temperature In Fahrenheit?

Jan 11, 2014

I am trying to create a java file that will print out the temperature in Fahrenheit. This is my code.

import java.util.Scanner;
 public class TemperatureConverter { 
public static void main(String[] args) {
 float temperature;
Scanner in= new Scanner(System.in);
 System.out.printf("Enter temperature in degrees Celsius: ");
temperature = in.nextInt();
//Getting a red X next to this line.
fahrenheit = temperature * 9/5 +32;
//Add this line
System.out.printf(+temperature + " degrees Celsius is " + fahrenheit + " degrees Fahrenheit.");
 //System.out.println(temp1 + " degrees celsius is " + fahrenheit + " degrees Fahrenheit.");

}

I need to know what I am doing wrong. Using Eclipse as my platform. I have entered comments where I am getting red X's.

The error I get when I run the program.

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
fahrenheit cannot be resolved to a variable
fahrenheit cannot be resolved to a variable
at TemperatureConverter.main(TemperatureConverter.jav a:24)

View Replies View Related

Program To Convert Temperature

Apr 24, 2014

Write a program that will provide temperature conversions between degrees Fahrenheit and degrees Celsius. Provide a method that will take an argument representing a temperature in Fahrenheit degrees and return the equivalent temperature in degrees Celsius. Also provide a method that will take an argument representing a temperature in degrees Celsius and return the equivalent temperature in degrees Fahrenheit. Conversion formulas are as follows: F = 9./5. * C + 32, C = 5./9. * ( F - 32 ), where F = Fahrenheit temperature and C = Celsius temperature. You must prompt for input using the Input class methods that are provided as a download for this unit.

I have two questions, 1st is why won't I get an output from my program when I run it? 2nd is how do I prompt for input using the Input class methods downloaded? The downloaded files are in .class form, and won't show any output when I run them.My code is:

import java.util.*;
public class temp
{
public static void main ( String [] args )
{
Scanner in = new Scanner(System.in);

[code]...

View Replies View Related

Temperature Conversion Project - Send Input Value To Calculation Area And Get Value To Display In JLabel

Sep 30, 2014

The problem I'm trying to resolve now is getting my ActionEvent to send the value input in the JTextArea out to be calculated, then to display the result in my result JLabel.

Here is an image of the GUI :

The basic procedure the teacher is asking for is the user is supposed to enter a temperature in the input. The user then clicks the input scale, and then on the output scale selection the converted value is to be displayed in the output area.

As I mentioned my problem is in the sending of the input value to my calculation area, and getting the value to display in the JLabel.

How should I approach this solution? Do I need to have a listener after the JTextArea of the input box? Will that allow me to limit the input values to numbers only?

final JTextArea inputText = new JTextArea("" + (char)176,1,4);
//ReadConsole equivalent to specific input was a number?

Here is the section of code my ActionListener is:

//celOut represents the Celcius output scale JRadioButton.
celOut.addActionListener (new ActionListener () {

@Override
public void actionPerformed(ActionEvent e) {
//if the Celcius Input Scale is selected.
if(cel.isSelected())

[Code] ....

All the calculations are required to occur in a separate java file, which what I think is tripping me up. How do I send a value from the JTextArea into the Calc.celToFahr method?

//contents of my Calc.java calculation class.
public class Calc {
public static double celToFahr(double cel){
return cel * (9./5.) + 32.;
}
public static double fahrToCel(double fahr){
return (fahr - 32.)*(5./9.);
}
}

View Replies View Related

GUI Program - Convert Input Name To Number

Mar 12, 2015

A GUI program that allows user to enter their name and the program will convert it in number using array.

For example if i input "EUNISE" the output should be 521149195

Because the letter equivalent of

a = 1
b = 2
c = 3
d = 4
e = 5
f = 6
g = 7
h = 8
i = 9
j = 10
k = 11
l = 12
m = 13
n= 14
o = 15
p = 16
q = 17
r= 18
s = 19
t = 20
u = 21
v = 22
w = 23
x = 24
y = 25
z = 26

View Replies View Related

How To Convert System Input Into Array

Jul 18, 2014

Creating an array searcher wherein it all depends on the user input. On the first user input it would be the array to search from while the second input would be something to be searched for inside the loop?

View Replies View Related

Input Binary Value And Convert It Into Decimal And Vice Versa

Jan 9, 2015

I am new to java programming and using bluej for programming and i have tried this question what i have have given in title ... How to do the following question without using strings.

Write a java program to input a binary value and convert it into decimal and Vice Versa. Without using String. Please make it for blue j format.

View Replies View Related

User Input Data As String And If Verified As Valid Number Then Convert Into Double

Nov 11, 2014

I am writing a code in which a user inputs data as a string and that data must be verified as a valid number. A valid number is anything from 0-100. Then all valid numbers are converted into double numbers.

I am having trouble in how to write the validation part of the code.

Is it suppose to be an if, else statement? And if so how is it suppose to be validated?

View Replies View Related

How To Convert Input Array Of Type Strings To Class Type

Aug 14, 2014

class Passenger{
String name;
int age;
char gender;
int weight;
public Passenger(){

[Code] ....

This is showing error.....error it gives isthat it cannot change from string type to passenger type......... How to do it??????

View Replies View Related

GUI Temperature Converter

May 4, 2015

I am having calculation issues converting Fahrenheit to Celsius. The Celsius to Fahrenheit is working properly.

private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
int tempFahr = (int)((Double.parseDouble(tempText.getText()))
* 1.8 + 32);// Calculate Fahrenheit to Celsuis:
fahrenheitLabel.setText(tempFahr + "Fehrenheit");
}

[code]...

View Replies View Related

High / Low / Average Temperature

Nov 19, 2014

I am trying to write a code that asks the user to enter a temperature for each day of the week and then it prints out the high temperature, the low temperature, and the average temperature. This is the code I have so far:

import java.util.*;
import java.text.DecimalFormat;
public class Lab10 {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
int high, low, i, sum;
double avg;
[Code] ....

There are a few issues that I am having.

1. I can't for the life of me figure out how to make it print the low temperature
2. I had it running perfectly until I changed one thing and now I get a compile error saying that the last 5 statements are unreachable. (lines 32-37)

View Replies View Related

Temperature Conversion GUI Java

Apr 21, 2015

I'm having trouble getting the text entered in my JTextField to be converted to the conversion formula. The line I'm getting error in is:

String text = text.getText();

Also I created another JTextField in which I want the answer to be displayed in, but I'm not too sure how to go about that.
This is my attempt at it, but it doesn't work because it doesn't make sense;
result.setText1(Integer.toString(celsius));

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TempConversion extends JFrame
{
private final JLabel ask;
private final JLabel result;
private final JTextField text;
private final JTextField text1;

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved