Explanation on how problem was solved

User Generated

alpenml

Computer Science

Description

There are two problems and solutions attached. I need an explanation on how the problem was solved. Thanks!

Unformatted Attachment Preview

1.) (Page 114, exercise 3.26) Write a program that prompts the user to enter an integer and determines whether it is divisible by 5 and 6, whether it is divisible by 5 or 6, and whether it is divisible by 5 or 6, but not both. Here is a sample run of this program: import java.util.Scanner; public class Exercise_03_26 { public static void main(String[] args) { Scanner input = new Scanner(System.in); // Create Scanner object // Prompt user to an integer System.out.print("Enter an integer: "); int number = input.nextInt(); // Determine whether it is divisible by 5 and 6 // Display results System.out.println("Is 10 divisible by 5 and 6? " + ((number % 5 == 0) && (number % 6 == 0))); System.out.println("Is 10 divisible by 5 or 6? " + ((number % 5 == 0) || (number % 6 == 0))); System.out.println("Is 10 divisible by 5 of 6, but not both? " + ((number % 5 == 0) ^ (number % 6 == 0))); } } 2.) (Page 284, exercise 7.28) Write a program that prompts the user to enter 10 integers and displays all combinations of picking two numbers from the 10 numbers: import java.util.ArrayList; import java.util.Scanner; public class combinations { /** * @param args */ public static void main(String[] args) { System.out.println("Enter 10 integers"); Scanner sc = new Scanner(System.in); String s = sc.next(); ArrayListints= new ArrayList(); ArrayListcombos = new ArrayList(); while(ints.size()
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

...


Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Content

Related Tags