Convert Celsius to Kelvin and Fahrenheit in the Required Order

Quick Overview

Convert a Celsius temperature to numeric Kelvin and Fahrenheit values in the required order using the supplied formulas.

Convert Celsius to Kelvin and Fahrenheit in the Required Order

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Given nonnegative Celsius temperature `celsius`, rounded to two decimal places, return `[kelvin, fahrenheit]` using: - `kelvin = celsius + 273.15` - `fahrenheit = celsius * 1.80 + 32.00` Return numeric values in that order. Absolute error within `10^-5` of each actual result is accepted. ```cpp class Solution { public: vector<double> convertTemperature(double celsius); }; ``` ### Examples **Example 1:** ```text Input: celsius = 0.00 Output: [273.15000,32.00000] Explanation: Substitute zero into the two supplied formulas. ``` **Example 2:** ```text Input: celsius = 100.00 Output: [373.15000,212.00000] Explanation: The Kelvin result is 100+273.15, and Fahrenheit is 100*1.8+32. ``` ### Constraints - `0 <= celsius <= 1000`. - The supplied nonnegative floating-point input is rounded to two decimal places. ### Clarifying Questions - Which value comes first? Kelvin, followed by Fahrenheit. - Should results be strings formatted to two decimals? No; return two double values. - Must the Fahrenheit value be rounded to two decimals? No; use the supplied formula and accepted numeric tolerance. ```hint Check the boundary Check the required output order at zero Celsius. ```

Overview: Convert a Celsius temperature to numeric Kelvin and Fahrenheit values in the required order using the supplied formulas.

Amazon logo
Amazon
Source window: 0–6 months · as of Oct 21, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Given nonnegative Celsius temperature celsius, rounded to two decimal places, return [kelvin, fahrenheit] using:

  • kelvin = celsius + 273.15
  • fahrenheit = celsius * 1.80 + 32.00

Return numeric values in that order. Absolute error within 10^-5 of each actual result is accepted.

class Solution {
public:
    vector<double> convertTemperature(double celsius);
};

Examples

Example 1:

Input: celsius = 0.00
Output: [273.15000,32.00000]
Explanation: Substitute zero into the two supplied formulas.

Example 2:

Input: celsius = 100.00
Output: [373.15000,212.00000]
Explanation: The Kelvin result is 100+273.15, and Fahrenheit is 100*1.8+32.

Constraints

  • 0 <= celsius <= 1000 .
  • The supplied nonnegative floating-point input is rounded to two decimal places.

Clarifying Questions Guidance

  • Which value comes first? Kelvin, followed by Fahrenheit.
  • Should results be strings formatted to two decimals? No; return two double values.
  • Must the Fahrenheit value be rounded to two decimals? No; use the supplied formula and accepted numeric tolerance.