Write a Java program to generate 10 random numbers between 0 and 99, figure out the...
Fantastic news! We've Found the answer you've been seeking!
Question:
![Write a Java program to generate 10 random numbers between 0 and 99, figure out the prime numbers in them,](https://dsd5zvtm8ll6.cloudfront.net/questions/2023/12/658019fa15628_1702984040833.jpg)
Transcribed Image Text:
Write a Java program to generate 10 random numbers between 0 and 99, figure out the prime numbers in them, and count the number of prime numbers (hint: consult Section 5.11 in the Textbook on finding prime numbers). The program should implement an is Prime method to test if a number is a prime number as follows: public class HW6_2 { } public static void main(String[] args) { …..... } public static boolean isPrime (int n) The following are two sample runs of the program: Sample run 1 Ten random numbers are: 64 87 92 41 92 19 83 63 87 73 The prime numbers in the list are: 41 19 83 73. The number of prime numbers: 4 Sample run 2 Ten random numbers are: 16 20 68 84 90 18 19 9 65 53 The prime numbers in the list are: 19 53 The number of prime numbers: 2 Write a Java program to generate 10 random numbers between 0 and 99, figure out the prime numbers in them, and count the number of prime numbers (hint: consult Section 5.11 in the Textbook on finding prime numbers). The program should implement an is Prime method to test if a number is a prime number as follows: public class HW6_2 { } public static void main(String[] args) { …..... } public static boolean isPrime (int n) The following are two sample runs of the program: Sample run 1 Ten random numbers are: 64 87 92 41 92 19 83 63 87 73 The prime numbers in the list are: 41 19 83 73. The number of prime numbers: 4 Sample run 2 Ten random numbers are: 16 20 68 84 90 18 19 9 65 53 The prime numbers in the list are: 19 53 The number of prime numbers: 2
Expert Answer:
Answer rating: 100% (QA)
Below is a simple Java program that generates 10 random numbers between 0 and 99 finds the prim... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Great Furniture Inc. (GF) manufactures a variety of furniture for household use and just two items for office use: desks and cabinets. The production process for desks and cabinets is similar,...
-
Consider the following grammar G={S XTU | IX | X T->c || X -> XX | U U -> Y | VP | P Y-> X | V P->IP | } (i). Check that the resulting grammar is LL(1) (ii). Construct the LL(1) parsing table for the...
-
2. Solve the following, and where necessary, give your answer to 3 decimal places: (a) 42x-3=10 (b) 34-72x+5
-
Lowell Inc. projects unit sales for a new project with a life of FOUR YEARS as follows: year 1 = Unit sales 10,000 Year 2 = Unit sales 12,000 Year 3 = Unit sales 14,000 Year 4 = Unit sales 16,000...
-
For the information provided in Problem 13, compute the expected value of perfect information (EVPI) as discussed in Supplementary Chapter SC E. Clearly explain how to interpret EVPI for Edwards...
-
Discuss the benefits of strategic management AppendixLO1
-
5. Property taxes are considered: a Derived tax revenues b Imposed nonexchange revenues c Government-mandated nonexchange transactions d Voluntary nonexchange transactions
-
1. Are Amazon.coms warehouses, Web pages, and one-click sales methods fully redeployable to other products? If so, name a few such products. If not, why not? 2. Are Borders fixed assets fully...
-
The assignment is to prepare a Ratio Analysis which are useful in understanding a Company. Ratio Analysis is used in conjunction with the other types of analysis discussed in this module. The ratios...
-
Morelli Electric Motor Corporation manufactures electric motors for commercial use. The company produces three models. designated as standard. deluxe. and heavy-duty. The company uses a job order...
-
The summarized balance sheets of Ivanhoe Company and Dobbs Company as of December 31, 2018 are as follows: IvanhoeCompany Balance Sheet December 31,2018 Assets$2480000 Liabilities$320000Capital...
-
Could you please check and send me the last results, because the system announced the wrong answer. Thanks Question 1 George was offered two options for a car he was purchasing: Lease option: Pay...
-
Context This task requires analysing a network scenario, design the network architecture and recommend IT solutions including ethical, security and sustainability considerations.The purpose of this...
-
What was the Prime Cost Percent for Mandy's BBQ Pit for August? Select one: a. 46.5% b. 73.9% c. 63.4% d. 85%
-
Finding Critical Values and Confidence Intervals. In Exercises 5-8, use the given information to find the number of degrees of freedom, the critical values x? and x*, and the confidence interval...
-
An investor sold 100 shares of ABC stock short at $25 and buys one ABC Jan 30 call @ $5. What is this investor's maximum gain, maximum loss, and breakeven points from this strategy?
-
Fire Company is a service firm with current service revenue of $900,000 and a 40% contribution margin. Its fixed costs are $200,000. Ice Company has current sales of $420,000 and a 30% contribution...
-
Test your confidence in the following Project Decisions: SI. # Question 01 02 03 04 05 06 07 08 09 10 How many years did it take to construct the largest Egyptian Pyramid- Pyramid of Cheops? When was...
-
Rewrite Programming Exercise 20.5 using a thread to animate bouncing ball movements. The example in Section displays multiple bouncing balls. Extend the example to detect collisions. Once two balls...
-
Write a method that finds the smallest element in an array of double values using the following header:public static double?min(double[] array)Write a test program that prompts the user to enter ten...
-
Rewrite Listing 15.13 using a thread to animate a flag being raised. Compare the program with Listing 15.13 by setting the delay time to 10 in both programs. Which one runs the animation faster?...
-
26. Which of the following is most likely to be true about the financial reporting of a public college or university? a. It resembles the financial reporting of private colleges and universities. b....
-
27. On January 1, 2008, a city government leased the following pieces of equipment. Each lease qual ifies as a capital lease. Initial payments are on December 31, 2008. An interest rate of 10 percent...
-
28.On January 1, 2008, a city government leased the following pieces of equipment. Each lease qual ifies as a capital lease. Initial payments are on December 31, 2008. An interest rate of 12 percent...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App