to find hcf and lcm using constructor in java
#1

to find hcf and lcm using constructors in java
Reply
#2
Find HCF & LCM of Two Numbers

To find the HCF and LCF of two number in Java Programming, you have to ask to the user to enter the two number, to find the HCF and LCF of the given two number to display the value of the HCF and LCM of the two numbers on the output screen as shown in the following program.

Java Programming Code to Find HCF LCM of Two Numbers

Following Java Program ask to the user to enter any two number to find HCF & LCM, then display the result on the screen :

/* Java Program Example - Find HCF LCM of Two Numbers */

import java.util.Scanner;

public class JavaProgram
{
public static void main(String args[])
{
int a, b, x, y, t, hcf, lcm;
Scanner scan = new Scanner(System.in);

System.out.print("Enter Two Number : ");
x = scan.nextInt();
y = scan.nextInt();

a = x;
b = y;

while(b != 0)
{
t = b;
b = a%b;
a = t;
}

hcf = a;
lcm = (x*y)/hcf;

System.out.print("HCF = " +hcf);
System.out.print("\nLCM = " +lcm);
}
}
When the above Java Program is compile and executed, it will produce the following output:

Java Program find hcf lcm
Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:

C Find HCF LCM
C++ Find HCF LCM
Python Find HCF LCM.
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: finding lcm hcf using vedic mathschnology in health care, ppt for hcf and lcm, www xnxx lcm, hcf generator in vhdl with code, hcf tricks hindi pdf, how to find the accident place using the fuzzy and zigbee, c programe of lcm and hcf of two numbers,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  well-spring some homemade barbecue backchat and moistureless rubs and the actuality 0 1,040 10-09-2019, 05:48 PM
Last Post:
  agent some homemade barbecue cheek and prosaic rubs and suit 0 959 10-09-2019, 07:04 AM
Last Post:
  pass some homemade barbecue coolness and arid rubs and module 0 911 09-09-2019, 06:35 PM
Last Post:
  program for ticket reservation using multithreading in java 0 1,067 08-10-2018, 10:00 AM
Last Post: Guest
  icse java projects class 10 free download 0 850 25-09-2018, 10:32 PM
Last Post: Guest
  find factorial of a number in lex 0 614 25-09-2018, 12:12 PM
Last Post: Guest
  java source code for voice based email for blinds 0 736 25-09-2018, 09:40 AM
Last Post: Guest
  techmax core java book pdf download 0 657 20-09-2018, 12:54 PM
Last Post: Guest
  full project on enhancing lan using cryptography and other modules 0 631 16-08-2018, 01:19 PM
Last Post: Guest
  Recruitment and selection procedure in itc limited and hul ltd 1 1,598 13-08-2018, 08:20 AM
Last Post: Alima

Forum Jump: