mkdir ~/cs170/lab8 # make lab directory cd /home/cs170001/share/labs/lab8 # Go to share folder with lab8 cp * ~/cs170/lab8 # Make a copy to your folder cd ~/cs170/lab8 # Go back to your lab folder
I believe that you have work enough with BlueJ to turn Non-BlueJ Java projects into a BlueJ one.
Your task is to write the following program in the GCD.java file. The program first reads in 2 integer numbers a and b. Then the program computes and prints the Greastest Common Divider (GCD) of the numbers a and b.
The GCD of a and b is the largest integer n, such that:
a / n has a remainder 0AND
b / n has a remainder 0
The number of integers is infinite, so you need to limit the range to search.
Use these facts to limit the range:
A common divider is a number n, such that:
a / n has a remainder 0AND
b / n has a remainder 0
Enter a: 36 Enter b: 48 The GCD of 36 and 48 is 12 Enter a: 96 Enter b: 72 The GCD of 96 and 72 is 24
cd ~/cs170/lab8 /home/cs170001/turnin GCD.java lab8