Write a test class to test the method isPrime in Listing 6.7 PrimeNumberMethod. java. Data from Listing
Question:
Write a test class to test the method isPrime in Listing 6.7 PrimeNumberMethod. java.
Data from Listing 6.7
Transcribed Image Text:
1 public class PrimeNumber Method { 2 pub11c static void main(String[] args) { System.out.printin("The first 50 prime numbers are in"): printPrimeNumbers (50): 3 4 6 publ1c static void printPrimeNumbers (1nt numberofPrimes) { final int NUMBER_OF_PRIMES_PER_LINE = 10: II Display 10 per line 1nt count = 0; II Count the number of prime numbers 7 8 9 10 Int number = 2: II A number to be tested for primeness 11 II Repeatedly find prime numbers wh1le (count < numberofPrimes) { // Print the prime number and increase the count 1f (isPrime(number)) { count++; /7 Increase the count 12 13 14 15 16 17 1f (count % NUMBER_OF_PRIMES_PER_LINE = 0) { II Print the number and advance to the new line 18 19
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 71% (7 reviews)
public class ABC Main Method public static void main String args int ...View the full answer
Answered By
Joash Mokaya
I am an experienced tutor with more than 7 years of experience. I have helped thousands of students pursue their academic goals. My primary objective as a tutor is to ensure that students have an easy time handling their academic tasks.
0.00
0 Reviews
10+ Question Solved
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Write a test class to test the methods length, charAt, substring, and indexOf in the java.lang.String class.
-
Write a test class to test the methods add, remove, addAll, removeAll, size, isEmpty, and contains in the java.util.HashSet class.
-
Write a test class to test the methods getBMI and getStatus in the BMI class in Listing 10.4. Data from Listing 10.4. 1 publ1c class BMI { private String name: private int age: private double weight:...
-
According to the Internal Revenue Service (IRS), the chances of your tax return being audited are about 1 in 100 if your income is less than $1 million and 9 in 100 if your income is $1 million or...
-
Consider X, Y with joint density fX,Y(x,y) = 9/64x2y2, for 0 x,y 2, 0 y 2, and fX,Y(x,y) = 0 otherwise. a. Find P(X < 1,Y < 1). b. Find P(X > l,y < 1). c. Find P(X > 1, Y > 1). d. Check that the...
-
The chapter discusses the importance of being nimble in all aspects of a firms operation that is, to be in a position to be maximally flexible, adaptable, and speedy in response to change. a....
-
If your instructor assigns a marketing plan for your class, we hope you will be excitedfor two reasons. First, you will get insights into trying to actually do marketing that often go beyond what you...
-
Omega Company is considering three capital expenditure projects. Relevant data for the projects are as follows. Annual income is constant over the life of the project. Each project is expected to...
-
Provide an objective setting paragraph on HP Inc.'s decision to increase the R&D investment to use towards their partnership with Poly Solutions to enhance Microsoft Teams flexibility
-
Richard Pitkin, CFO of Draper Corporation, was concerned by the long-term prospects for the Synectics product line. The product line had performed well historically, but the impending loss of its...
-
Write a program that converts a red-black tree to a 2-4 tree.
-
Write a JSP that prompts the user to enter a capital for a state, as shown in Figure 38.16a. Upon receiving the user input, the program reports whether the answer is correct, as shown in Figure...
-
Draw a generic picture of a fuel cell. What is the main difference between it and a battery, regardless of the redox reactions that occur inside?
-
Consider the below code. #include using namespace std; class Count { public: int count; }; Count(int c) { } } count = c; Count() { count- 0; void increment (Count c, int times) c.count++; times++; }...
-
A 0.40-kg mass is attached to a spring with a force constant of k = 257 N/m, and the mass-spring system is set into oscillation with an amplitude of A = 3.5 cm. Determine the following. (a)...
-
Week 5 Section B: Create a comprehensive system for human talent management (W5LO1, W5LO2. W5L03, CLO2, CLO3, and CLO 6) In this task, you will demonstrate your ability to develop a comprehensive...
-
. An inverted pendulum is supported by a linear spring, as shown in Fig. 1.76. It is required to: (a) Derive the equation for the angular motion 6(r) about O. (b) Determine the equilibrium positions.
-
3. Suppose we have a sorted array of 5000 elements. What is the maximum number of comparisons done by the Binary Search algorithm? Show work. 4. Give the Big O notation for the following functions...
-
In any hydraulic system, it is important to "bleed" air out of the line. Why?
-
What exactly is a prima facie duty? How does an ethic of prima facie duties differ from monistic and absolutist ethical theories?
-
Describe an implementation of the positional list methods addLast and addBefore realized by using only methods in the set {isEmpty, first, last, before, after, addAfter, addFirst}.
-
The add method for a dynamic array, as described in Code Fragment 7.5, has the following inefficiency. In the case when a resize occurs, the resize operation takes time to copy all the elements from...
-
Suppose we are maintaining a collection C of elements such that, each time we add a new element to the collection, we copy the contents of C into a new array list of just the right size. What is the...
-
Current Attempt in Progress The following information is available for Blossom Corp. for the year ended December 31, 2027: Other revenues and gains $9,000 Sales revenue $592,000 Other expenses and...
-
What are the six Vs of data? The process of data cleansing is what type of data analytics challenge? What is the main difference between qualitative and quantitative data? What is the...
-
Alfred and Beulah received taxable interest income of $ 5 0 0 . Alfred and Beulah received a $ 1 , 9 0 0 refund on their 2 0 2 1 state income taxes; they claimed the standard deduction on their 2 0 2...
Study smarter with the SolutionInn App