96,743 views
42 votes
42 votes
Import java.util.Scanner;

public class TemperatureConversion {
public static double celsiusToKelvin(double valueCelsius) {
double valueKelvin;

valueKelvin = valueCelsius + 273.15;

return valueKelvin;
}

/* Your solution goes here */

public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
double valueC;
double valueK;

valueC = 10.0;
System.out.println(valueC + " C is " + celsiusToKelvin(valueC) + " K");

valueK = scnr.nextDouble();
System.out.println(valueK + " is " + kelvinToCelsius(valueK) + " C");
}
}

User Salec
by
2.8k points

1 Answer

21 votes
21 votes

Answer:

import java.util.Scanner;

public class TemperatureConversion {

public static double celsiusToKelvin(double valueCelsius) {

double valueKelvin;

valueKelvin = valueCelsius + 273.15;

return valueKelvin;

}

public static double kelvinToCelsius(double valueKelvin) {

double valueCelsius;

valueCelsius = valueKelvin - 273.15;

return valueCelsius;

}

/* Your solution goes here */

public static void main (String [] args) {

Scanner scnr = new Scanner(System.in);

double valueC;

double valueK;

valueC = 10.0;

System.out.println(valueC + " C is " + celsiusToKelvin(valueC) + " K");

System.out.println("Input Kelivin: ");

valueK = scnr.nextDouble();

System.out.println(valueK + " is " + kelvinToCelsius(valueK) + " C");

}

}

Step-by-step explanation:

User SNO
by
3.0k points