Program Javascript untuk Mengubah Celsius ke Fahrenheit

0
(0)

Anda dapat mengonversi nilai celsius menjadi fahrenheit dengan menggunakan rumus:

fahrenheit = celsius * 1.8 + 32

Contoh: Celsius ke Fahrenheit

// program to convert celsius to fahrenheit
// ask the celsius value to the user 
const celsius = prompt("Enter a celsius value: ");

// calculate fahrenheit
const fahrenheit = (celsius * 1.8) + 32

// display the result
console.log(`${celsius} degree celsius is equal to ${fahrenheit} degree fahrenheit.`);

Keluaran

Enter a celsius value: 55
55 degree celsius is equal to 131 degree fahrenheit.

Dalam program di atas, pengguna memasukkan nilai celsius dan disimpan di file Celsius variabel. Kemudian rumus fahrenheit digunakan untuk mengubah nilai celsius menjadi fahrenheit.


Anda dapat mengonversi nilai fahrenheit ke celsius menggunakan rumus:

celsius = (fahrenheit - 32) / 1.8

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.