Loading

LeetCode problem#2469

Convert the Temperature

Solved in 3 languagesJavaC++C#

Solve it on LeetCode(opens in a new tab)

Solution

10 lines
1class Solution {
2    public double[] convertTemperature(double celsius) {
3        double[] ans = new double[2];
4
5        ans[0] = celsius + 273.15;
6        ans[1] = 1.8 * celsius + 32.0;
7
8        return ans;
9    }
10}
1class Solution {
2public:
3    vector<double> convertTemperature(double celsius) {
4        return { celsius + 273.15, celsius * 1.8 + 32 };
5    }
6};
1public class Solution {
2    public double[] ConvertTemperature(double celsius) {
3        return new double[] { celsius + 273.15, celsius * 1.8 + 32 };
4    }
5}

Want a walkthrough of this Java solution?

Get a step-by-step explanation of the idea behind the code.

All problems

Problem statements belong to LeetCode and are on leetcode.com. We're not affiliated with LeetCode.