Math Program 1 Answer(s) 3 years and 4 months ago
Posted in : Java Beginners
The greatest common divisor of two integers 16 and 24 is 8. Develop the algorithm for finding the greatest common divisor of two numbers. Write a program that prompts the user to enter two integers and calculates the GCD for the entered numbers.
View Answers
March 3, 2010 at 11:46 AM
Hi Friend,
Try the following code:
import java.util.*; class GCD{ public static int determineGCD(int a, int b) { if (b==0) return a; else return determineGCD(b, a % b); } public static void main(String[] args)throws Exception { GCD cal = new GCD(); Scanner input=new Scanner(System.in); System.out.println("Enter first number: "); int num1=input.nextInt(); System.out.println("Enter second number: "); int num2=input.nextInt(); int gcd = cal.determineGCD(num1, num2); System.out.println("GCD of two numbers= "+gcd); } }
Thanks
Related Pages:
Math Program - Java Beginners Math Program The greatest common divisor of two integers 16 and 24 is 8.
Develop the algorithm for finding the greatest common divisor of two numbers. Write a program that prompts the user to enter two integers and calculates
class Math - Java Beginners
its ok?"
Complete a program that asks the user a floating-point number (either positive or negative).The program repeats while the user enters 'y'to continue.The program allows the user to enter either a lowercase or uppercse character.Use
Java - Math class in Java
. to manipulate the mathematical operation in your program.
The Math class is used...
Java - Math class in Java
In this example you will learn about Math class. This example
Java math class
Java math class Can you instantiate the Math class
java Math class
java Math class Why are the methods of the Math class static
Java math class
Java math class Why can?t I say just abs() or sin() instead of Math.abs() and Math.sin
Summary: Math Class
Java Summary: Math Class
In this section we will study about the Match class of Java API.
Some basic math functions can be found in the Math class...;
double ar; // angle in radians.
x is any of int, long, float, or double.
Math
Summary: Math and java.util.Random Classes
Java Summary: Math and java.util.Random Classes
In this section we will discuss Math and java.util.Random classes.
Both these classes can be used for generating the random numbers.
Some basic math functions can be found in the Math
Can you instantiate the Math class? - Java Beginners
Can you instantiate the Math class? Hi,
Can you create object of Math class?
Thanks
Hi,
All the methods in Math class is static. The constructor is not public in the Math class. So, we can't create
Mysql Math Function
Mysql Math Function
Math Function involved in Mysql when we perform some operation... 'Mysql Math Function'. The below
Syntax help you to perform Math Function :
ABS(X
Mysql Math Function
Mysql Math Function
Math Function involved in Mysql when we perform some operation... from 'Mysql Math Function'.The below
Syntax help you to perform Math Function :
ABS
how to write the program - Java Beginners
how to write the program WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects
Lang
Hindi
History
Geography
Math
Phy
Chem.
Bio
Eve
CSTA
Also has a back up
Normal Distribution java program?
Normal Distribution java program? For my last assignment i have... knows java: Write a program to tabulate the cumulative normal distribution F(z...);
}
}
public static double gaussian() {
double U = Math();
double V = Math();
return
program
program any program of hotel or school management
program
program program of jdbc using ms access for creating table
program
program write a javascript program to create a application form with validation
program
program write a html program in show table and this word
in box
program
program write a program different between to dates in terms of days in java
Randomizer
by using the random() method of the Math class and change them
into different... random numbers on the console.
Description of program:
In the given... by the randomFloat() method by
using the round() method of the Math class. Now we
program
program Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program write a program reversee a string.
input-hi this is roseindia
output-roseindia is this hi
program
program develop a servlet to insert the data in the database from our program in the table stored in the database
program
program WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program explanation of program on extending thread class
Hi Friend,
Please go through the following link:
Java Threads
Thanks
program
program Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
Program
Program a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = â??Tommyâ?? age=â??23â?? and call this constructor
Program
Program a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
program
program no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program
program Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program Write a program to print details of a week for a particular day using array of objects Integer and String.
OUTPUT:
First Day of Week is Monday
Second Day of Week is Tuesday
Third Day of Week is Wednesday
Forth Day