Menu Close

Compute foot and inches into centimetres

Many people think about their height in feet and inches, even in some countries that primarily use the metric system. Write a program that reads a number of feet from the user, followed by a number of inches.
Once these values are read, your program should compute and display the equivalent number of centimetres.

Hint: One foot is 12 inches. One inch is 2.54 centimetres.

Input:
Feet:  7
Inch's:  1

Output:
Your height in centimeters is  215.90 
import java.io.*;
import java.util.*;
public class temp {
	 public static void main(String[] args) {
       double foot,inch,cm=0;
       Scanner scan = new Scanner(System.in);
       System.out.println("Enter the Height Feet and Inches:  ");
       foot = scan.nextDouble();
       foot *= 30.48;
       inch = scan.nextDouble();
       inch *= 2.54;
       cm = foot + inch;
       System.out.println(String.format("Your height in centimeters is %.2f",cm));
	}
}

INPUT_1:
Enter the Height Feet and Inches:
5
7

OUTPUT:
Your height in centimeters is  170.18


INPUT_2:
Enter the Height Feet and Inches:
6
1

OUTPUT:
Your height in centimeters is  185.42


INPUT_3:
Enter the Height Feet and Inches:
6
5

OUTPUT:
Your height in centimeters is  195.58


INPUT_4:
Enter the Height Feet and Inches:
7
5

OUTPUT:
Your height in centimeters is  226.06


INPUT_5:
Enter the Height Feet and Inches:
5
5

OUTPUT:
Your height in centimeters is  165.10


ILLUSTRATION

eXecuted using javac in linux terminal 😉

Morae Q!

  1. Convert from binary number to decimal number.
  2. Swap two numbers by using division and multiplication.
  3. Compute foot and inches into centimetres.
  4. Concatenate Strings.
  5. Convert lowercase letters to uppercase letters.
  6. Compute the sum of all the digits of N.
  7. Compute the area of the pentagon.
  8.  Get input using scanner.
  9. Find the distance between two points (x1,y1) and (x2,y2).
  10. Finding patterns in a file using frep and egrep .
  11. Detecting a cycle in a directed graph using Depth First Traversal.
  12. Topological ordering in a Graph.
  13. Storing graphs using adjacency list.
  14. Introduction to graph theory.
  15. Graph Adjacency Matrix pseudo code.
  16. Adjacency Matrix for storing graphs.
  17. Dijkstra’s shortest path algorithm .
  18. Breadth first search (BFS) Algorithm.
  19. Find the multiple of given number in the list of integers.
  20. Finding patterns in files using grep .