15 points TASK 2 Update Task 1 You may use your IDE or Text
(15 points) TASK 2: Update Task 1: (You may use your IDE or Text File to execute program.)
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 *
* 2) Is Input divisible by 5 or 6 *
* 3) Is 10 divisible by 5 or 6, but not both *
* 4) Quit *
**************************************
1)
Enter an integer:
10 // Users enters 10
Is 10 divisible by 5 and 6? No
(Attach snipping photo of source code and output.)
Solution
import java.util.*;
public class Divisibility
{
boolean div1(int n)
{
return ((n%5==0) && (n%6==0));
}
boolean div2(int n)
{
return ((n%5==0) || (n%6==0));
}
boolean div3()
{
return ((10%5==0) && (10%6==0));
}
public static void main(String args[])
{
int x = 0, y = 0;
do
{
System.out.println(\"*MAIN MENU\");
System.out.println(\"1) Run Program\");
System.out.println(\"2) Is input divisible by 5 or 6\");
System.out.println(\"3) Is input divisible by 5 and 6\");
System.out.println(\"4) Is 10 divisible by 5 or 6\");
System.out.println(\"5) Quit\");
Scanner s = new Scanner(System.in);
System.out.println(\"Enter A Choice\");
y = s.nextInt();
Divisibility d = new Divisibility();
switch(y)
{
case 1: main(null);
break;
case 2: System.out.println(\"Enter an integer\");
x = s.nextInt();
System.out.println(d.div1(x));
break;
case 3: System.out.println(\"Enter an integer\");
x = s.nextInt();
System.out.println(d.div2(x));
break;
case 4: System.out.println(d.div3());
break;
case 5: System.exit(0);
break;
}
}
while(y!=5);
}
}

