In this article I would like to share with you a sample program that I wrote in Java programming language Inches To Centimeter Converter. The program will ask the user to enter a value in inches and then it converted it to its centimeter equivalent.
I hope you will find my work useful in a sense the logic of programming is also applied in this simple program.
If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
People here in the Philippines can reach me at my mobile number 09173084360.
Thank you very much and Happy Programming.
People here in the Philippines can reach me at my mobile number 09173084360.
Thank you very much and Happy Programming.
Sample Program Output
Program Listing
import java.util.Scanner;
import java.text.DecimalFormat;
class inches_to_centimeter
{
public static double convert_to_centimeters(double inches)
{
double solve_centimeters = (inches * 2.54);
return(solve_centimeters);
}
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("###.##");
char a;
do
{
System.out.print("\n");
System.out.println("==============================================");
System.out.println("|| <<< Inches To Centimeter Converter >>> ||");
System.out.println("==============================================");
System.out.print("\n");
System.out.print("How many length in inches? :=> ");
double get_inches = scan.nextDouble();
System.out.println("\n");
System.out.println("=======================");
System.out.println("|| DISPLAY RESULT ||");
System.out.println("=======================");
System.out.println("\n");
System.out.print("The given length in inches is " + df.format(get_inches) +
" the equivalent length in centimeters is " +df.format(convert_to_centimeters(get_inches))+ " cms.");
System.out.println("\n\n");
System.out.print("Do you Want To Continue (Y/N) :=> ");
a=scan.next().charAt(0);
} while(a=='Y'|| a=='y');
System.out.println("\n");
System.out.println("\t ===== END OF PROGRAM ======");
System.out.println("\n");
}
} // End of Program