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: 80% (10 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...
-
Draw two vector field diagrams, one for a particle carrying charge \(+q\) and located at the origin of a rectangular coordinate system and one for a particle carrying charge \(-2 q\) and located at...
-
Give examples of how a board member can increase the organization s social, intellectual, and fi nancial capacity.
-
Kathleen and Mary (KM) operate a small coffee shop. They produce regular coffee available from many other similar businesses and also produce gourmet coffee for special orders. Their accountant...
-
North Wind Aviation received its charter during January authorizing the following capital stock: Preferred stock: 8 percent, par $10, authorized 20,000 shares. Common stock: par $1, authorized 50,000...
-
Use Algorithm 5.4 to approximate the solutions to the initial-value problems in Exercise 2. In Exercise 2 a. y' = (2 2ty)/(t2 + 1), 0 t 1, y(0) = 1, with h = 0.1 actual solution y(t) = (2t + 1)/(t2...
-
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...
-
Jasper Company uses a job costing system. Overhead is allocated based on 120 per cent of direct labour cost. Last months transactions in the work in process account are shown here: Only one job,...
-
Identify and briefly describe the types of authoritative pronouncements issued by the SEC.
-
Enumerate the principal duties of the Chief Accountant.
-
Find the area under the standard normal curve to the left of a. z = 0.74 b. z = 2.16 c. z = 1.02 d. z = 0.15
-
What conclusions do you draw about (a) yourself as a consumer, and (b) the performance of each of the businesses in Exercise 1? Assess whether any of these businesses managed to develop a sustainable...
-
Describe the responsibilities and primary functions of the Division of Corporation Finance.
-
Gitano Products operates a job-order costing system and applies overhead cost to jobs on the basis of direct materials used in production (not on the basis of raw materials purchased). Its...
-
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...
-
Example 8: A metal building costing $39,995.00 was purchased from Bob's Buildings. A down payment of $7,000.00 was made at the time of purchase, and it was agreed that 36 monthly payments of...
-
ABC Limited located in a country which has a capital gains tax, conducted the following transactions: a. Purchased a building in February 2018 for $26,000,000. In March 2019, the company spent $2,...
-
Suppose you sell a fixed asset for $ 1 1 9 , 0 0 0 when its book value is $ 1 3 9 , 0 0 0 . If your companys marginal tax rate is 2 1 percent, what will be the effect on cash flows of this sale ( i ....
Study smarter with the SolutionInn App