Using &&, 11 operators) Write a program that prompts the user to enter an intege
ID: 3926220 • Letter: U
Question
Using &&, 11 operators) Write a program that prompts the user to enter an integer and determines whether it is divisible by 5 and 6, and whether it is divisible by 5 or 6. Place the above code into a do-while/switch case menu Allow the user to choose which operation she will perform Main Menu Enter # to run program or Quit 1) Is Input divisible by 5 and 6 1) Is Input divisible by 5 and 6 1) Is Input divisible by 5 and 6 1) Enter an integer 10//Users enters 10 Is 10 divisible by S and 6? No 2) Enter an integer 10//Users enters 10 Is 10 divisible by 5 or 6? Yes (Attach snipping photo of source code and output.)Explanation / Answer
#include <iostream>
#include<math.h>
using namespace std;
int main() {
// your code goes here
int number;
int choice;
do
{
cout << "Main Menu Enter # to run program or Quit." << endl;
cout << "1) Is Input divisible by 5 and 6" << endl;
cout << "2) Is Input divisible by 5 or 6" << endl;
cout << "3) Quit." << endl;
cin >> choice;
switch(choice)
{
case 1:
cout << "Enter an integer : " << endl;
cin >> number;
if(number%5==0 && number%6==0)
cout << "Is Input divisible by 5 and 6?" << " Yes." << endl;
else
cout << "Is Input divisible by 5 and 6?" << " No." << endl;
break;
case 2:
cout << "Enter an integer : " << endl;
cin >> number;
if(number%5==0 || number%6==0)
cout << "Is Input divisible by 5 or 6?" << " Yes." << endl;
else
cout << "Is Input divisible by 5 or 6?" << " No." << endl;
break;
case 3:
break;
default:
cout << "Invalid choice." << endl;
break;
}
}while(choice!=3);
return 0;
}
OUTPUT:
Main Menu
Enter # to run program or Quit.
1) Is Input divisible by 5 and 6
2) Is Input divisible by 5 or 6
3) Quit.
1
Enter an integer :
10
Is Input divisible by 5 and 6? No.
Main Menu
Enter # to run program or Quit.
1) Is Input divisible by 5 and 6
2) Is Input divisible by 5 or 6
3) Quit.
2
Enter an integer :
10
Is Input divisible by 5 or 6? Yes.
Main Menu
Enter # to run program or Quit.
1) Is Input divisible by 5 and 6
2) Is Input divisible by 5 or 6
3) Quit.
3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.