write a Java program that prints asks the user to enter a positive value (1 less than or equal to 200) and print each number up to that line, 1 per line with the following changes (SNAP CRACKLE POP). • If a number is ***** by 2 (but not 3 or 5) print out SNAP instead of the integer. • If a number is ***** by 3 (but not 2 or 5) print out CRACKLE instead of the integer. • If a number is ***** by 5 (but not 2 or 3) print out POP instead of the integer. • If a number is ***** by 2 and 3 (but not 5) print out SNAPCRACKLE instead of the integer. • If a number is ***** by 2 and 5 (but not 3) print out SNAPPOP instead of the integer. • If a number is ***** by 3 and 5 (but not 2) print out CRACKLEPOP instead of the integer. • If a number is ***** by 2, 3, and 5 print out SNAPCRACKLEPOP instead of the integer. Sample Runs: Enter a positive value: 7 1 SNAP CRACKLE SNAP POP SNAPCRACKLE 7 Enter a positive value: 10 1 SNAP CRACKLE SNAP POP SNAPCRACKLE 7 SNAP CRACKLE SNAPPOP

The task requires creating a Java program that prompts the user to enter a positive value between 1 and 200. The program should then print each number up to the given value, with certain modifications based on divisibility. If a number is divisible by 2 but not by 3 or 5, the program should print “SNAP” instead of the number. If a number is divisible by 3 but not by 2 or 5, it should print “CRACKLE” instead. If a number is divisible by 5 but not by 2 or 3, it should print “POP.”

If a number is divisible by 2 and 3 but not by 5, the program should print “SNAPCRACKLE”. Similarly, if a number is divisible by 2 and 5 but not by 3, it should print “SNAPPOP”. If a number is divisible by 3 and 5 but not by 2, it should print “CRACKLEPOP”. Lastly, if a number is divisible by 2, 3, and 5, it should print “SNAPCRACKLEPOP”.

To illustrate the program’s functionality, let’s consider two sample runs.

Sample Run 1:

Enter a positive value: 7

The program will print the following sequence:

1
SNAP
CRACKLE
SNAP
POP
SNAPCRACKLE
7

Sample Run 2:

Enter a positive value: 10

The program will print the following sequence:

1
SNAP
CRACKLE
SNAP
POP
SNAPCRACKLE
7
SNAP
CRACKLE
SNAPPOP

To implement this program, we can use a loop that starts from 1 and iterates up to the given value. At each iteration, we evaluate the conditions for divisibility and print the corresponding output.

Here’s an example Java program that accomplishes this task:

“`java
import java.util.Scanner;

public class SnapCracklePop {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.print(“Enter a positive value: “);
int value = scanner.nextInt();

for (int i = 1; i <= value; i++) { if (i % 2 == 0 && i % 3 == 0 && i % 5 == 0) { System.out.println("SNAPCRACKLEPOP"); } else if (i % 2 == 0 && i % 3 == 0) { System.out.println("SNAPCRACKLE"); } else if (i % 2 == 0 && i % 5 == 0) { System.out.println("SNAPPOP"); } else if (i % 3 == 0 && i % 5 == 0) { System.out.println("CRACKLEPOP"); } else if (i % 2 == 0) { System.out.println("SNAP"); } else if (i % 3 == 0) { System.out.println("CRACKLE"); } else if (i % 5 == 0) { System.out.println("POP"); } else { System.out.println(i); } } } } ``` In this program, we first prompt the user to enter a positive value and store it in the `value` variable. Then, we use a `for` loop to iterate from 1 to the given value. Inside the loop, we use a series of `if` statements to check the divisibility conditions and print the corresponding output. If none of the conditions are met, we print the number itself.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer