010-003-002

Method Overloading: Temperature Conversion

Easy

Problem Description

method overloading: Temperature Conversion

In this problem, you will create a program that defines convertToFahrenheit methods overloaded with three parameter types (int, double, and String) to convert Celsius to Fahrenheit and displays the results to standard output.

Learning Objective: Implement different processing by parameter type using overloading

Define convertToFahrenheit method with same name but different parameter types (int, double, String) to convert Celsius to Fahrenheit. Implement calculation processing for each type.

Input

3 lines from standard input:

  1. Integer value (Celsius temperature passed as int type)
  2. Decimal value (Celsius temperature passed as double type)
  3. Numeric string (Celsius temperature passed as String type)

Output

[celsius]C = [fahrenheit]F

(3 lines of output)

Conversion formula: Fahrenheit = Celsius × 9/5 + 32

Examples

Example 1: Basic values

Input:

0
25.5
30

Output:

0C = 32F
25.5C = 77.9F
30C = 86.0F

Example 2: Different values

Input:

100
37.5
15

Output:

100C = 212F
37.5C = 99.5F
15C = 59.0F

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
10
22.5
5
Expected Output:
10C = 50F
22.5C = 72.5F
5C = 41.0F
Normal case
Input:
75
12.5
60
Expected Output:
75C = 167F
12.5C = 54.5F
60C = 140.0F

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 10 free executions remaining