Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Code a Java temperature converter in 7 minutes! 🌡️
Play lesson

Java tutorial for beginners ☕ - Code a Java temperature converter in 7 minutes! 🌡️

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#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(); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere