0% found this document useful (0 votes)
10 views2 pages

Temperatura Java

The document contains a Java program that converts temperatures between Celsius and Fahrenheit. It defines a class 'Temperatura' with methods for the conversions and takes user input for temperature. The execution example shows the conversion of 50 degrees Celsius to Fahrenheit and vice versa.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Temperatura Java

The document contains a Java program that converts temperatures between Celsius and Fahrenheit. It defines a class 'Temperatura' with methods for the conversions and takes user input for temperature. The execution example shows the conversion of 50 degrees Celsius to Fahrenheit and vice versa.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PANTALLAZO:

CODIGO FUENTE:
import java.util.Scanner;

public class Temperatura {

private double grado;

public Temperatura(double grado) {

this.grado = grado;

public double celsiusAFahrenheit() {

return (grado * 1.8) + 32;

public double fahrenheitACelsius() {

return (grado - 32) / 1.8;

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);


System.out.print("Ingrese los grados: ");

double grado = scanner.nextDouble();

Temperatura temp = new Temperatura(grado);

System.out.println(grado + "°C son " + temp.celsiusAFahrenheit() + "°F");

System.out.println(grado + "°F son " + temp.fahrenheitACelsius() + "°C");

EJECUCION DEL PROGRAMA:


Ingrese los grados: 50
50.0°C son 122.0°F
50.0°F son 10.0°C

You might also like