Tag Archives: Fahrenheit To Celsius

Frequently Asked Algorithms & Java Programs


Below are most frequently asked algorithms and programs in interview to test interviewee programming and logical skill. These question can be asked with fresher and any senior level programmers to check hands on with the code or not.

  1. Write a program to print alphabet using java loop
    Output:
    a b c d e f g h i j k l m n o p q r s t u v w x y z
    a b c d e f g h i j k l m n o p q r s t u v w x y z
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  2. Write a program to check odd or even number.
    Input:  5
    Output: Odd Number
  3. Write a program to convert Fahrenheit to Celsius.
    Input: 50
    Output: 10.0
  4. Write a java program to print fibonacci series without using recursion and using recursion.
    Input: 12
    Output: 0 1 1 2 3 5 8 13 21 34 55 89 144
  5. Write a java program to check prime number.
    Input: 42
    Output: Not prime number
    Input: 13
    Output: Prime number
  6. Write a java program to check palindrome number.
    Input: 349
    Output: Not palindrome number
    Input: 1234321
    Output: Palindrome number
  7. Write a java program to print factorial of a number.
    Input: 4
    Output: 24
    Input: 5
    Output: 120
  8. Write a java program to check Armstrong number.
    Input: 153
    Output: Armstrong number
    Input: 22
    Output: Not Armstrong number
  9. Write a program to swap numbers without using third variable.
    Input: 20 30
    Output: 30 20
  10. Write a program to reverse of number.
    Input:    123456
    Output: 654321
  11. Write a program to find largest of three numbers.
    Input: 10 30 40
    Output: 40
  12. Write a program to print Floyd triangle.
    Input: 7
    Output:

    1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 14 15
    16 17 18 19 20 21
    22 23 24 25 26 27 28

Sorting Program

  1. Write a java program to sort an array elements using bubble sort algorithm.
    Input:    2 6 3 8 4 1 5 0
    Output: 0 1 2 3 4 5 6 8
  2. Write a java program to sort an array elements using selection sort algorithm.
    Input:    2 6 3 8 4 1 5 0
    Output: 0 1 2 3 4 5 6 8
  3. Write a java program to sort an array elements using insertion sort algorithm.
    Input:    2 6 3 8 4 1 5 0
    Output: 0 1 2 3 4 5 6 8
  4. Write a java program to sort an array elements using quick sort algorithm.
    Input:    12 24 45 56 10 9 49 30 5 15
    Output: 5 9 10 12 15 24 30 45 49 56
  5. Write a java program to sort an array elements using heap sort algorithm.
    Input:    2 6 3 8 4 1 5 0
    Output: 0 1 2 3 4 5 6 8
  6. Write a java program to sort an array elements using merge sort algorithm.
    Input:    12 24 45 56 10 9 49 30 5 15
    Output: 5 9 10 12 15 24 30 45 49 56
  7. Write a java program to sort an array elements using shell sort algorithm.
    Input:    2 6 3 8 4 1 5 0
    Output: 0 1 2 3 4 5 6 8
  8. Write a java program to sort an array elements using radix sort algorithm.
    Input:   170 45 75 90 2 802 2 66
    Output: 2 2 45 66 75 90 170 802
  9. Write a java program to sort an array elements using bucket sort algorithm.
    Input:   0.23 0.67 0.32 0.25 0.88 0.45 0.86 0.16 0.59 0.38 0.19 0.43 0.02
    Output: 0.02 0.16 0.19 0.23 0.25 0.32 0.38 0.43 0.45 0.59 0.67 0.86 0.88
  10. Write a java program to sort an array elements using counting sort algorithm.
    Input:    2 6 3 2 8 4 8 1 5 3 1 4 0
    Output: 0 1 1 2 2 3 3 4 4  5 6 8 8

Java Searching Programs

  1. Write a java program to perform linear search in java.
  2. Write a java program to perform binary search in java.
Advertisements

Fahrenheit To Celsius Java Program


This program is to convert Fahrenheit to Celsius temperature based on user input value. Below is mathematical formula for conversion from Fahrenheit to Celsius temperature .

T = 9*T/5 + 32 where T is temperature on Celsius scale.

import java.util.Scanner;

class FahrenheitToCelsius {
	  public static void main(String[] args) {
	    float temperatue;
	    Scanner in = new Scanner(System.in);      

	    System.out.println("Enter Temperatue in Fahrenheit");
	    temperatue = in.nextInt();

	    temperatue = ((temperatue - 32)*5)/9;

	    System.out.println("Converted Temperatue in Celsius = " + temperatue);
	  }
	}

Outout

Enter Temperatue in Fahrenheit
100
Converted Temperatue in Celsius = 37.77778

Enter Temperatue in Fahrenheit
50
Converted Temperatue in Celsius = 10.0

Enter Temperatue in Fahrenheit
75
Converted Temperatue in Celsius = 23.88889

More

For more Algorithms and Java Programing Test questions and sample code follow below links