Question

In: Computer Science

Java Write a program that displays all the numbers from 100 to 200 that are divisible...

Java

Write a program that displays all the numbers from 100 to 200 that are divisible by 5 or 6, but not both

Make sure all instructions and outputs for the user are explicit

Solutions

Expert Solution

Java code:

public class Main{
public static void main(String[] args){
//printing a message to user about what this program does
System.out.println("All numbers between 100 and 200 that are divisible by 5 or 6, but not both are:");
//looping from 100 to 200
for(int i=100;i<=200;i++){
//checking if the number is divisible by 5 or 6 and not both
if((i%5==0 || i%6==0) && !(i%5==0 && i%6==0))
//printing the number
System.out.println(i);
}
   }
}


Screenshot:


Output:


Related Solutions

JAVA Write a program to sum the numbers from 1 to 100 that are divisible by...
JAVA Write a program to sum the numbers from 1 to 100 that are divisible by 7, and compute the average of those numbers, print both the sum and the average with appropriate messages to the screen. Run the program. Capture the console output. Put the program code and console output at the end of your text file,
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by...
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by sum of the digits in them. For example, 2924 is divisible by (2+9+2+4 = 17). Your program should display all these possible numbers in the given range, and each number should be separated from the other by a space.
in java Write a program that reads in ten numbers and displays the number of distinct...
in java Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly one space (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read a number and store it to an array if it is new. If the number is already in the array, ignore it.) After the input, the array contains the distinct numbers. Here is the sample run of the program: Enter...
Using the Python program: a/ Write a program that adds all numbers from 1 to 100...
Using the Python program: a/ Write a program that adds all numbers from 1 to 100 to a list (in order). Then remove the multiples of 3 from the list. Print the remaining values. b/ Write a program that initializes a list with ten random integers from 1 to 100. Then remove the multiples of 3 and 5 from the list. Print the remaining values. Please show your work and explain. Thanks
Write a Java program that reads words from a text file and displays all the non-duplicate...
Write a Java program that reads words from a text file and displays all the non-duplicate words in ascending order. The text file is passed as a command-line argument. Command line argument: test2001.txt Correct output: Words in ascending order... 1mango Salami apple banana boat zebra
(Use the GenericStack class) Write a program that displays the first 100 prime numbers in descending...
(Use the GenericStack class) Write a program that displays the first 100 prime numbers in descending order. Use a stack to store the prime numbers.
write java program that prompt the user to enter two numbers .the program display all numbers...
write java program that prompt the user to enter two numbers .the program display all numbers between that are divisible by 7 and 8 ( the program should swap the numbers in case the secone number id lower than first one please enter two integer number : 900 199 Swapping the numbers 224 280 336 392 448 504 560 616 672 728 784 840 896 i need it eclipse
write java program that prompt the user to enter two numbers .the program display all numbers...
write java program that prompt the user to enter two numbers .the program display all numbers between that are divisible by 7 and 8 ( the program should swap the numbers in case the secone number id lower than first one please enter two integer number : 900 199   Swapping the numbers 224 280 336 392 448 504 560 616 672 728 784 840 896 i need it eclipse
Java Programming Write a program that displays the following pattern *                         *       &nbsp
Java Programming Write a program that displays the following pattern *                         *          *          * *          *          *          *          *          *          *          *          *          *          *          *             *          *          *          *          *                         *          *          *                                     * Printing Pattern A * ** *** **** ***** ****** ******* Printing Pattern B ******* ****** ***** **** *** ** * Printing Pattern C * ** *** **** ***** ****** *******
Write a Java program that reads a name and displays on the screen.
Write a Java program that reads a name and displays on the screen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT