Question

Randomly generate an integer number in range [1, 999], (a) Check if this number is even...

Randomly generate an integer number in range [1, 999], (a) Check if this number is even or odd, display message “[number] is an even number” or “[number] is an odd number”. For example, if the number is 10, display message “10 is an even number”. (b) Check if this number is divisible by 7 and 11. Display message showing result (c) Check if this number is divisible by 9 or 13. Display message showing result (d) Check if this number is divisible by 5 or 12, but not both. Display result

In Java Please

Homework Answers

Answer #1

Required program in JAVA -->

import java.util.Random;
public class Main{
   public static void main(String args[])
   {
       Random rand = new Random();
       int number = rand.nextInt(1000); //randomly generate a value between 0 to 1000
       System.out.println("Random Number: "+number); // show the randomly generated number
       if(number%2==0){ // if number%2==0 means if number is even
       System.out.println(number+" is even number"); // print number is even
       }
       else{ // number is odd
       System.out.println(number+" is odd number"); //print number is odd
       }
       if(number%7==0 && number%11==0){ //if number is divisible by 7 and 11
       System.out.println("Number is divisible by 7 and(&&) 11"); //print divisible
       }
       else{ // if number is not divisible by 7 and 11
       System.out.println("Number is not divisible by 7 and(&&) 11"); //print not divisible
       }
       if(number%9==0 || number%13==0){ //if number is divisible by 9 or 13
       System.out.println("Number is divisible by 9 or(||) 13"); //print divisible
       }
       else{ //if number is not divisible by 9 or 13
       System.out.println("Number is not divisible by 9 or(||) 13"); //print not divisible
       }
       if(number%5==0 || number%12==0){ //if  number is divisible by 5 or 12
       System.out.println("Number is divisible by 5 or(||) 12"); //print divisible
       }
       else{ // if number is not divisible by 5 or 12
       System.out.println("Number is not divisible by 5 or(||) 12"); //print not divisible
       }
   }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Randomly generate an integer number in range [10, 99]. Write a program to check if the...
Randomly generate an integer number in range [10, 99]. Write a program to check if the digit at 10’s position is less than the digit at 0’s position. If yes, swap these 2 digits. Display original number and new number. For example, if the number generated is 53, after process, the new number will be 35. If original number is 12, no process needed. If the number is 50, the new number will be 5. in Java please
In Java : Randomly generate an integer number in range [10, 99]. Write a program to...
In Java : Randomly generate an integer number in range [10, 99]. Write a program to check if the digit at 10’s position is less than the digit at 0’s position. If yes, swap these 2 digits. Display original number and new number. For example, if the number generated is 53, after process, the new number will be 35. If original number is 12, no process needed. If the number is 50, the new number will be 5.
Write a program that prompts the user to enter an integer number between 1 and 999....
Write a program that prompts the user to enter an integer number between 1 and 999. The program displays the sum of all digits in the integer if the input is valid; otherwise, it displays a message indicating that the integer is not between 1 and 999 and hence, is invalid. Name the program file Q1.cpp Example: if the user enters 12, sum of digits is 3. If the user enters 122, sum of digits is 5.
A prime number is an integer greater than 1 that is evenly divisible by only 1...
A prime number is an integer greater than 1 that is evenly divisible by only 1 and itself. For example, 2, 3, 5, and 7 are prime numbers, but 4, 6, 8, and 9 are not. Create a PrimeNumber application that prompts the user for a number and then displays a message indicating whether the number is prime or not. Hint: The % operator can be used to determine if one number is evenly divisible by another. ( Java programing...
Write program to generate random numbers in different range and display: (c) A number in range...
Write program to generate random numbers in different range and display: (c) A number in range [0, 10) (d) A number in range [0, 1000] (e) A number in range [-99, 99] (f) A double number in range [1000.0, 9999.0) In Java Please
Write a program that asks the user for a number in the range 1 through 12....
Write a program that asks the user for a number in the range 1 through 12. The program should display the corresponding month of the year, where 1 = January, 2 = February, 3 = March, 4 = April, 5 = May, 6 = June, 7 = July, 8 = August, 9 = September, 10 = October, 11 = November, and 12 = December. The program should display an error message if the user enters a number that is outside...
8. It is possible to check if an integer is divisible by 9 by summing its...
8. It is possible to check if an integer is divisible by 9 by summing its digits: if the digits add up to 9 the number is divisible by 9. For integers up to 90 only a single application of the rule is required. For larger integers, multiple applications may be required. For example, for 99, the digit sum is 18. Then, because 18 still has multiple digits we sum them again to get 9, confirming that 99 is divisible...
Write a java program to display a given range of integer numbers (0 to 9) in...
Write a java program to display a given range of integer numbers (0 to 9) in the following order: Example : given (5 to 9), the program displays 56789 67895 78956 89567 95678 The first line displays the min to max range. Each line that follows should display the next higher number except when it hits the maximum number. In that situation, the line wraps back to the minimum sequence. For this problem write a static method to do the...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop (instead of for). • The function takes a single integer n as a parameter • The function prints a series between 1 and that parameter, and also prints its result • The result is calculated by summing the numbers between 1 and n (inclusive). If a number is divisible by 5, its square gets added to the result instead. • The function does not...
JAVA a. An integer is a "Lucky Number" if it is divisible by 7 or is...
JAVA a. An integer is a "Lucky Number" if it is divisible by 7 or is divisible by 11 and it is in the range 1000 through 4000. Write a Boolean expression that is true if and only if myNum (an int variable) contains a Lucky Number. b. Let a and b represent the length and the width of a rectangle. The length of the diagonal of the rectangle can be calculated by the following mathematical expression. diagonalLength = squareRoot(a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT