top of page
Writer's pictureRahul Kumar

Fahrenheit to Celsius Table

Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their corresponding Celsius values and print the table.


Input Format :
3 integers - S, E and W respectively
Output Format :
Fahrenheit to Celsius conversion table. One line for every Fahrenheit and corresponding Celsius value. The Fahrenheit value and its corresponding Celsius value should be separate by single space.

Constraints :

0 <= S <= 90
S <= E <= 900
0 <= W <= 80

Sample Input :

0
100
20

Sample Output :

0 -17
20 -6
40 4
60 15
80 26
100 37

Solution :


import java.util.Scanner;
public class Solution {


	public static void main(String[] args) {
		
		/* Your class should be named Solution.
	 	* Read input as specified in the question.
	 	* Print output as specified in the question.
		*/
        Scanner input = new Scanner(System.in);

		int s = input.nextInt();
        int e = input.nextInt();
        int w = input.nextInt();
        
        while(s <= e){
        int cel = ((5*(s-32))/9);
        System.out.println(s+" "+cel);
        s=s+w;
        }
	}

}

Recent Posts

See All

Number Pattern 1

Print the following pattern Pattern for N = 4 1 23 345 4567 Input Format : N (Total no. of rows) Output Format : Pattern in N lines...

Comments


bottom of page