Algorithm Sample - Inch to Cm convertion


package algorithmsample7;

import java.util.Scanner;

/**
 *
 * @author Nurhak
 */
public class AlgorithmSample7 {

    public static void main(String[] args) {
        String data = "";
        double dataInch = 0;
        double dataCm = 0;
        try {
            Scanner scan = new Scanner(System.in);

            System.out.println("Please enter data (inch)");
            data = scan.nextLine();
            dataInch = Double.parseDouble(data);

            dataCm = dataInch * 2.54;
            System.out.println(dataInch + " inch equals to " + dataCm + " cm.");

        } catch (Exception e) {
            System.err.println("You probably entered a wrong value like a String value!");
        }
    }
}

Comments

Popular posts from this blog

Solution for "Can not obtain Oracle client information from registry"

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Getting Umbraco Content - IPublishedContent vs IContent vs Node vs Document