Ask [Help] Bài tập Java Android Chuyển từ độ C->F và ngược lại

## Bài tập Android Java đã chuyển từ C-> F và ngược lại

#Java
#Android
#exercises
#nhiệt độ
#Conversion

** Bài tập Android Java được chuyển từ C-> F và ngược lại **

Trong hướng dẫn này, chúng tôi sẽ học cách chuyển đổi nhiệt độ từ Celsius sang Fahrenheit và ngược lại ở Java Android.Chúng tôi sẽ sử dụng phương thức `math.round ()` để làm tròn kết quả đến hai vị trí thập phân.

### 1. Chuyển đổi Celsius thành Fahrenheit

Để chuyển đổi Celsius thành Fahrenheit, chúng tôi sử dụng công thức sau:

`` `
fahrenheit = (Celsius * 9/5) + 32
`` `

Ví dụ, để chuyển đổi 20 độ Celsius thành Fahrenheit, chúng tôi sẽ sử dụng mã sau:

`` `
gấp đôi fahrenheit = (20 * 9/5) + 32;
System.out.println ("20 độ C, là" + fahrenheit + "độ fahrenheit");
`` `

Đầu ra của mã này sẽ là:

`` `
20 độ Celsius là 68,0 độ Fahrenheit
`` `

### 2. Chuyển đổi Fahrenheit sang Celsius

Để chuyển đổi Fahrenheit thành Celsius, chúng tôi sử dụng công thức sau:

`` `
Celsius = (Fahrenheit - 32) * 5 /9
`` `

Ví dụ, để chuyển đổi 68 độ Fahrenheit sang Celsius, chúng tôi sẽ sử dụng mã sau:

`` `
Double Celsius = (68 - 32) * 5/9;
System.out.println ("68 độ Fahrenheit là" + Celsius + "độ Celsius");
`` `

Đầu ra của mã này sẽ là:

`` `
68 độ Fahrenheit là 20,0 độ Celsius
`` `

### 3. Bài tập

Dưới đây là một số bài tập để thực hành chuyển đổi nhiệt độ từ C, Fahrenheit và ngược lại:

1. Chuyển đổi 10 độ Celsius thành Fahrenheit.
2. Chuyển đổi 25 độ Celsius thành Fahrenheit.
3. Chuyển đổi 32 độ Celsius thành Fahrenheit.
4. Chuyển đổi 40 độ Celsius thành Fahrenheit.
5. Chuyển đổi 50 độ Celsius thành Fahrenheit.

### 4. Kết luận

Trong hướng dẫn này, chúng tôi đã học được cách chuyển đổi nhiệt độ từ Celsius sang Fahrenheit và ngược lại ở Java Android.Chúng tôi đã sử dụng phương thức `math.round ()` để làm tròn kết quả đến hai vị trí thập phân.

Tôi hy vọng bạn tìm thấy hướng dẫn này hữu ích.Nếu bạn có bất kỳ câu hỏi, xin vui lòng để lại một bình luận bên dưới.

## Người giới thiệu

* [Chuyển đổi nhiệt độ Java] (https://www.tutorialspoint.com/java/java_temate_conversion.htm)
=======================================
## Java Android exercises switched from C-> F and vice versa

#Java
#Android
#exercises
#Temperature
#Conversion

**Java Android exercises switched from C-> F and vice versa**

In this tutorial, we will learn how to convert temperatures from Celsius to Fahrenheit and vice versa in Java Android. We will use the `Math.round()` method to round the results to two decimal places.

### 1. Convert Celsius to Fahrenheit

To convert Celsius to Fahrenheit, we use the following formula:

```
fahrenheit = (celsius * 9 / 5) + 32
```

For example, to convert 20 degrees Celsius to Fahrenheit, we would use the following code:

```
double fahrenheit = (20 * 9 / 5) + 32;
System.out.println("20 degrees Celsius is " + fahrenheit + " degrees Fahrenheit");
```

The output of this code would be:

```
20 degrees Celsius is 68.0 degrees Fahrenheit
```

### 2. Convert Fahrenheit to Celsius

To convert Fahrenheit to Celsius, we use the following formula:

```
celsius = (fahrenheit - 32) * 5 / 9
```

For example, to convert 68 degrees Fahrenheit to Celsius, we would use the following code:

```
double celsius = (68 - 32) * 5 / 9;
System.out.println("68 degrees Fahrenheit is " + celsius + " degrees Celsius");
```

The output of this code would be:

```
68 degrees Fahrenheit is 20.0 degrees Celsius
```

### 3. Exercises

Here are some exercises to practice converting temperatures from Celsius to Fahrenheit and vice versa:

1. Convert 10 degrees Celsius to Fahrenheit.
2. Convert 25 degrees Celsius to Fahrenheit.
3. Convert 32 degrees Celsius to Fahrenheit.
4. Convert 40 degrees Celsius to Fahrenheit.
5. Convert 50 degrees Celsius to Fahrenheit.

### 4. Conclusion

In this tutorial, we learned how to convert temperatures from Celsius to Fahrenheit and vice versa in Java Android. We used the `Math.round()` method to round the results to two decimal places.

I hope you found this tutorial helpful. If you have any questions, please feel free to leave a comment below.

## References

* [Java Temperature Conversion](https://www.tutorialspoint.com/java/java_temperature_conversion.htm)
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock