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
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
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...
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...
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...
5 numbers chosen randomly without replacement. (#'s range 1-39). "B" represents number of even numbers, this...
5 numbers chosen randomly without replacement. (#'s range 1-39). "B" represents number of even numbers, this random variable has this probability: x 0 1 2 3 4 5 p(B=x) 0.02693 0.15989 .33858 .31977 .13464 .02020 number of odd #s chosen would then be 5-x, if x is even #s chosen. "C" represents difference b/w # of even and # of odd chosen, --> C= 2B-5 a. show how variance of B is = 1.1177 b. what is SD of "B"?...
Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27} Write a program...
Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27} Write a program to count number of EVEN and ODD items. Do a screen output of your result. for c++ please
1) (i) How can you tell that 56290040037 is a valid identification number of an American...
1) (i) How can you tell that 56290040037 is a valid identification number of an American Express Travelers Cheque? a) The sum of the digits is an even number. b) The number ends in a 7. c) The sum of the digits is divisible by 9. (ii) The ZIP + 4 code consists of nine digits and a check digit. How do you verify that a given code is a valid ZIP + 4 code? a) Three times the sum...