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

Design and implement a Java program for programming exercise 5.11, page 193, fro

ID: 3673785 • Letter: D

Question

Design and implement a Java program for programming exercise 5.11, page 193, from the textbook (name it DivisiblesBy5And6). Design the program such it allows the user to re-run the program with a different inputs (that is, the beginning and ending values such as 100 to 200) in the same run. Document your code, and organize and space the outputs as specified (ten numbers per line, see program Multiples in Lab #6 on how to do that). Use escape characters and formatting objects when applicable.

5.11 (Find numbers divisible by 5 or 6, but not both) Write a program that displays
all the numbers from 100 to 200, ten per line, that are divisible by 5 or 6, but not
both. Numbers are separated by exactly one space.

Explanation / Answer

public class number
{
public static void main(String[] args)
{
int itemCount = 0;
for(int i=1; i<=1000; i++)
{
if(i%5 == 0 ^ i%6 == 0)
{
System.out.print(i + " ");
itemCount +=1;
if(itemCount==10){
System.out.println(" ");
itemCount = 0;
}
}
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote