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:
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: 9780133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions

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...

Explain why having relevant industry experience helps the founder of a firm?

A curve is such that The gradient of the curve at the point (0, 4) is 10. a. Express y in terms of x. b. Show that the gradient of the curve is never less than 4. dy 12x + 12. dx

Length of cross belt connecting two pulleys of radii \(r_{1}\) and \(r_{2}\) and at a center distance \(D\) apart, is: (a) \(\pi\left(r_{1}+r_{2} ight)+\left(r_{1}r_{2} ight)^{2} / D+2 D\) (b)...

Your client, Lewison International, has informed you that it has reached an agreement with Herro Company to acquire all of Herros assets. This transaction will be accomplished through the issue of...

Exercise 133 (Algo) Sourcing Decisions [LO133] Troy Engines, Limited, manufactures a variety of engines for use in heavy equipment. The company has always produced all of the parts for its engines,...

Calling the First Crusade, Pope Urban the II's Speech (Sources, 199) What is the purpose for calling on this first crusade, and who is commanding the people of Europe to go fight it, according to...

Discuss the ethics of the experiment. Relate the Stanford Prison Experiment to the potential stress in the practice of public accounting. Relate the roles assumed in a public accounting firm...

Today, over 400 million people stream music online. But instead of playing songs individually, many people now listen to music playlists that contain one or more songs. In this assessment, students...

Answer the questions given below. Question #3 Overhead Allocation Question #3 The lead accountant has compiled the following data in preparation for allocating overhead to three cost drivers....

Imagine that a manager in Japan just discovered that a team leader under their supervision has made a mistake that will result in a quality problem for the firm's next batch of production. Assuming...

An asset costs $760,000 and will be depreciated in a straightline manner over its threeyear life. It will have no salvage value. The lessor can borrow at 6.5 percent and the lessee can borrow at 8...

1. Suppose rocking chair manufacturing isa perfectly competitive industry in which there are 1,000 identical firms. Each firm's total cost is related to output per day as follows: (15 points)...

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?...

Cairo Corporation has government bonds classified as heldforcollection at December 31, 2015. These bonds have a par value of \($800\),000, an amortized cost of \($800\),000, and a fair value of...

On January 1, 2015, Meredith Corporation purchased 25% of the ordinary shares of Pirates Company for 200,000. During the year, Pirates earned net income of 80,000 and paid dividends of 20,000....

Komissarov Company has a debt investment in the bonds issued by Keune Inc. The bonds were purchased at par for 400,000 and, at the end of 2015, have a remaining life of 3 years with annual interest...
Study smarter with the SolutionInn App