Algorithm Sample - Division of two numbers that are inserted by the user


package algorithmsample4;

import java.util.Scanner;

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

    public static void main(String[] args) {
        double result = 0;
        double number1 = 0;
        double number2 = 0;
        String number = "";

        try {
            Scanner scan = new Scanner(System.in);
            System.out.println("Please enter the first number.");
            number = scan.nextLine();
            number1 = Double.parseDouble(number);

            System.out.println("Please enter the second number.");
            number = scan.nextLine();
            number2 = Double.parseDouble(number);

            result = number1 / number2;
            System.out.println("When we divide first number to second one, the result is: " + result);
        } catch (Exception e) {
        }

    }
}

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