Snippets Collections
// Formula	: (0°C × 9/5) + 32 = 32°F

import java.io.*;
import java.util.*;

class Solution
{
    public double cToF(int C)
    {
        return C*(9.0/5.0)+32.0;
    }
}

public class Main {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int T=sc.nextInt();//input number of testcases
		while(T-->0)
		{
		    Solution obj=new Solution();
		    
		    int C;
		    C=sc.nextInt();//input temperature in celscius
		    
		    System.out.println((int)(obj.cToF(C)));//print the output
		}
		
	}
}
star

Sun Feb 06 2022 01:30:39 GMT+0000 (UTC) https://practice.geeksforgeeks.org/problems/convert-celsius-to-fahrenheit/1/?track=DSASP-Mathematics&batchId=190

#java #mathematics #gfg #geeksforgeeks #convertcelsiustofahrenheit

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension