tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code07:56

Code a Java temperature converter in 7 minutes! 🌡️

Bro Code ↗

From the creator

#java #javatutorial #javacourse import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double temp; double newTemp; String unit; System.out.print("Enter the temperature: "); temp = scanner.nextDouble(); System.out.print("Convert to Celsius or Fahrenheit? (C or F): "); unit = scanner.next().toUpperCase(); // (condition) ? true : false newTemp = (unit.equals("C")) ? (temp - 32) * 5 / 9 : (temp * 5 / 9) + 32; System.out.printf("%.1f°%s", newTemp, unit); scanner.close(); } }

Published 2024-12-05 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code