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

x.Hmreate a menu-driven c++ program to calculate the greatest common divisor (GC

ID: 3616436 • Letter: X

Question

x.Hmreate a menu-driven c++ program to calculate the greatest common divisor (GCD) or lowest common denominator (LCD) given an input of two numbers. (Euclid's Algorithm). Menu:

• Option 1 prompts the user for two numbers. The program must print the following error
message and ignore the numbers if either is negative (zero is accepted):
• Wrong input: only positive numbers are allowed
• Option 2 prints the greatest common divisor of the two numbers input in option 1. Use the
Euclidean Algorithm to compute this value..... int GCD(int a, int b);
• Option 3 prints the lowest common denominator or the two numbers input in option 1. Use
the following formula to compute this value:
• Other selections should cause this error message to print before looping back to the menu:
• ‘?’ is an invalid choice! [where ? is the user’s invalid selection]
Sample output:
5.
6.
7. 0. Quit
8. 1. Enter numbers
9. 2. Compute greatest common divisor
10. 3. Compute lowest common denominator
11.
12. Selection : 1
13. Enter two numbers : -1 5
14. Wrong input: only positive numbers are allowed
15.
16. 0. Quit
17. 1. Enter numbers
18. 2. Compute greatest common divisor
19. 3. Compute lowest common denominator
20.
21. Selection : 1
22. Enter two numbers : 48 180
23. Input accepted
24.
25. 0. Quit
26. 1. Enter numbers
27. 2. Compute greatest common divisor
28. 3. Compute lowest common denominator
29.
30. Selection : 2
31. Greatest common divisor of 48 and 180 is 12
32.
33. 0. Quit
34. 1. Enter numbers
35. 2. Compute greatest common divisor
36. 3. Compute lowest common denominator
37.
38. Selection : 3
39. Lowest common denominator of 48 and 180 is 720
40.
41. 0. Quit
42. 1. Enter numbers
43. 2. Compute greatest common divisor
44. 3. Compute lowest common denominator
45.
46. Selection : 1
47. Enter two numbers : 3 13
48. Input accepted
49.
50. 0. Quit
51. 1. Enter numbers
52. 2. Compute greatest common divisor
53. 3. Compute lowest common denominator
54.
55. Selection : 2
56. Greatest common divisor of 3 and 13 is 1
57.
58. 0. Quit
59. 1. Enter numbers
60. 2. Compute greatest common divisor
61. 3. Compute lowest common denominator
62.
63. Selection : 3
64. Lowest common denominator of 3 and 13 is 39
65.
66. 0. Quit
67. 1. Enter numbers
68. 2. Compute greatest common divisor
69. 3. Compute lowest common denominator
70.
71. Selection : 0

Here's my code as of now. Its a little choppy as of now, but if I come across any more clues to what I need, I will post my code again. I found a easy way to calculate GCD, but then I realized that I didn't use the int GCD(int a, int b); prototype...

#include<iostream>
using namespace std;

int main ()
{

     int selection, top, bottom, left, num1, num2 = 0;
   

       
         cout << "0. Quit "
              << "1. Enter numbers "
              << "2. Compute greatest common divisor "
              << "3. Compute lowest common denominator " << endl;
              << "Selection : ";
            
          cin >> selection;
        
    while (n != 0){
      
        if (selection == 1) {
            cout << "Enter two numbers : ";
            cin >> num1 num2;}
        else if (selection == 2) {
       
            if (num1 > num2) {
                top = num1;
                bottom = num2;
                }
      
            else {
                top = num2;
                bottom = num1;
                }
      
                do{
                    left = top % bottom;
          
                    if(left != 0) {
                    top = bottom;
                    bottom = left;
                    }
        }
        while(remainder != 0);}
          
            else if (selection == 3) {
          
          
          
            else if (selection != 1 && selection != 2 && selection !=3) {
            cout << "'" << n << "' is the incorrect choice ";}
                cout << "0. Quit "
                     << "1. Enter numbers "
                     << "2. Compute greatest common divisor "
                     << "3. Co

Explanation / Answer

please rate - thanks #include using namespace std; int GCD(int,int); int main () {      int selection, left, num1, num2 =0;                      cout