How to program in Java: It turns out that cats are a lot smarter than the credit
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
It turns out that cats are a lot smarter than the credit given to them. They have learned to send simple encrypted messages to each other. These messages use a prime number as a key. Obviously, your cat doesn't want your dog to guess the key. This means your cat has to change the key at random times. However, being a cat, he's not very decisive about the number he wants. So, in exchange for not knocking your computer off your desk (he still gets to sit on your keyboard), he wants you to write a program that generates prime numbers. You will start off with 2, and generate the next prime number every time he presses the Enter key. Once he reaches a satisfactory prime number, he will hit '0', which is when you stop the program. Specifications • This program is worth 50 points, and is called Primes.java. • Create a class with the appropriate name. All of the code should be in the main method. (5 points) • You should generate the prime numbers in order. (25 points) • After printing a prime number, wait for user input. If the user presses Enter, generate the next prime number. Print a tab character after every prime number. If the user input were '0', stop the program. (15 points) • Please include comments wherever appropriate. (5 points) Sample Runs Regular text is what's printed by your program. Underlined text is user input, shown here as a sample. You will not be printing the underlined parts in your program. Sample Run 2 3 5 7 11 13 17 19 23 29 lo le le le 10 10 18/3/2/2 It turns out that cats are a lot smarter than the credit given to them. They have learned to send simple encrypted messages to each other. These messages use a prime number as a key. Obviously, your cat doesn't want your dog to guess the key. This means your cat has to change the key at random times. However, being a cat, he's not very decisive about the number he wants. So, in exchange for not knocking your computer off your desk (he still gets to sit on your keyboard), he wants you to write a program that generates prime numbers. You will start off with 2, and generate the next prime number every time he presses the Enter key. Once he reaches a satisfactory prime number, he will hit '0', which is when you stop the program. Specifications • This program is worth 50 points, and is called Primes.java. • Create a class with the appropriate name. All of the code should be in the main method. (5 points) • You should generate the prime numbers in order. (25 points) • After printing a prime number, wait for user input. If the user presses Enter, generate the next prime number. Print a tab character after every prime number. If the user input were '0', stop the program. (15 points) • Please include comments wherever appropriate. (5 points) Sample Runs Regular text is what's printed by your program. Underlined text is user input, shown here as a sample. You will not be printing the underlined parts in your program. Sample Run 2 3 5 7 11 13 17 19 23 29 lo le le le 10 10 18/3/2/2
Expert Answer:
Answer rating: 100% (QA)
Java program that prints prime numbers until the user ends the program import ja... View the full answer
Related Book For
Accounting Information Systems
ISBN: 978-0133428537
13th edition
Authors: Marshall B. Romney, Paul J. Steinbart
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Below is a paper for a Health Club called Biceps Concepts, to submit a CONTEXT DFD for this company, make sure you read the entire write up before creating your DFD. Biceps Concepts Mr. Fields...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
What are the main advantages and disadvantages of using 360 degree appraisal?
-
How much fiberglass insulation [k = 0.035 W/(m K)] is needed to guarantee that the outside temperature of a kitchen oven will not exceed 43?C? The maximum oven temperature to be maintained by the...
-
From the following clues involving topic matters covered that relate to accounting standards, concepts and the Framework, complete the crossword in figure 1.6. Across 2 Since January 2000 the AASB...
-
What stakeholder affected by their behavior was Gilead weighting very lightly when it decided what to tell the FDA about the medicines it wished to have permission to sell?
-
You have been asked to prepare a December cash budget for Ashton Company, a distributor of exercise equipment. The following information is available about the companys operations: (a) The cash...
-
Daniela built a raised garden bed that is 15 feet long, 6 feet wide, and 2.5 feet tall. She plans to fill the garden bed with premium soil that costs $15.96 per cubic yard. Recall that 1 yard = 3...
-
Use anonymous FTP to connect to ftp.rfc-editor.org (directory innotes), and retrieve the RFC index. Also retrieve the protocol specifications for TCP, IP, and UDP.
-
Anderson International Limited is evaluating a project in Erewhon. The project will create the following cash flows: Year 0 1 2 3 4 Cash Flow -$1,230,000 405,000 470,000 365,000 320,000 All cash...
-
If your company is facing a major issue, what is most likely to happen if you only fix its internal problems?
-
Mary had a large investment portfolio consisting of equities that she has held for many years. The securities appreciated significantly in value over the years. When she first bought these equities...
-
During preparation of your bid, you learn that there is local noise ordinance that limits the work hours due to limits to construction noise. What should we do?
-
The Heather Company's fiscal year ends on June 30.Its employees (with at least three months of experience) are entitled to 12 paid sick days annually for each calendar year beginning on January 1.An...
-
Name two actuarial assumptions that may be considered in valuing a defined benefit plan and explain why they are needed?
-
1. Solve the linear system { 0.211x1 + 0.811x2 = 1.52 1.71x1 1.06x2 = 0.512 using 3-digit chopping arithmetic and Gaussian elimination with partial pivoting. 2. The equation f (x) = 2 x2 sin x = 0...
-
If a process has a six-sigma capability, what is the process capability index? a. 1 b. 2 c. 6 d. 12
-
Refer to Problems 17.1 and 17.2 for information about the revenue and expenditure cycle activities for Joes ice-cream shop in order to draw an integrated REA diagram of both cycles.
-
Match the computer fraud and abuse technique in the left column with the scenario in the right column. Terms on the left may be used once, more than once, or not atall. 1. Dictionary attack a Spcal...
-
You are the director of internal auditing at a university. Recently, you met with Issa Arnita, the manager of administrative data processing, and expressed the desire to establish a more effective...
-
A project developed in PL/1 is expected to take 30 months. Assuming the same ratios as those shown in the table below, compare the duration, level of effort, and software size between a project...
-
What is the difference between tabular output and zoned output?
-
Develop a questionnaire for mass employee distribution based on your findings from the previous interviews. Why are we completing the analysis with an anonymous survey?
Study smarter with the SolutionInn App