Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Don\'t know how am suppose to expand this program in to developa new program tha

ID: 3614602 • Letter: D

Question

Don't know how am suppose to expand this program in to developa new program that computes both the GCD and the LCM
import java.util.Scanner; import java.io.*;
public class Euclid {
   public static int euclidGCD(int a, intb)    {    int rem= a %b;       while(rem !=0)    {    a=b;    b= rem;    rem =a%b;    }       return b;          }    public static void main(String[]args)
   {
   // System.out.println("Welcome to my first Booleanprogram!");
     System.out.println("This program will ask you to enter 2integers and calcualtes the GCD of those two numbers");
   int a, b;
   Scannerkeyboard = new Scanner(System.in);
     System.out.println("Please enter your first number,represented by 'a'; ");
   a=keyboard.nextInt();
   Scannerkeyboard1 = new Scanner(System.in);
     System.out.println("Please enter your second number,represented by 'b'; ");
   b=keyboard1.nextInt();
   if(a>b)      System.out.println("GCD of " + a +", " +b +" is: "+Euclid.euclidGCD(a,b));    else      System.out.println("GCD of " + a +", " +b +" is: "+Euclid.euclidGCD(b, a));               
} }
Don't know how am suppose to expand this program in to developa new program that computes both the GCD and the LCM
import java.util.Scanner; import java.io.*;
public class Euclid {
   public static int euclidGCD(int a, intb)    {    int rem= a %b;       while(rem !=0)    {    a=b;    b= rem;    rem =a%b;    }       return b;          }    public static void main(String[]args)
   {
   // System.out.println("Welcome to my first Booleanprogram!");
     System.out.println("This program will ask you to enter 2integers and calcualtes the GCD of those two numbers");
   int a, b;
   Scannerkeyboard = new Scanner(System.in);
     System.out.println("Please enter your first number,represented by 'a'; ");
   a=keyboard.nextInt();
   Scannerkeyboard1 = new Scanner(System.in);
     System.out.println("Please enter your second number,represented by 'b'; ");
   b=keyboard1.nextInt();
   if(a>b)      System.out.println("GCD of " + a +", " +b +" is: "+Euclid.euclidGCD(a,b));    else      System.out.println("GCD of " + a +", " +b +" is: "+Euclid.euclidGCD(b, a));               
} }

Explanation / Answer

please rate - thanks I've highlighted the changes import java.util.Scanner; import java.io.*; public class Euclid {     public static int euclidGCD(int a, int b)     {         int rem= a %b;                while(rem !=0)         {            a=b;            b= rem;            rem = a%b;         }                return b;                   }       public static void main(String[]args)       {           // System.out.println("Welcome to my first Boolean program!");            System.out.println("This program will ask you to enter 2 integersand calcualtes the GCD of those two numbers");            int a,b,GCD;            Scanner keyboard = new Scanner(System.in);            System.out.println("Please enter your first number, represented by'a'; ");            a =keyboard.nextInt();            Scanner keyboard1 = new Scanner(System.in);            System.out.println("Please enter your second number, represented by'b'; ");            b =keyboard1.nextInt();         if(a>b)            GCD= Euclid.euclidGCD(a,b);         else            GCD=Euclid.euclidGCD(b, a);                        System.out.println("GCD of " + a +", " +b +" is: "+GCD );                     System.out.println("LCMof " + a +", " +b +" is: "+(a*b)/GCD);         } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote