Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**PLEASE DO IT IN JAVA** Assignment 7.1 [45 points] This program is broken down into two phases for your convenience only. Please turn in only

**PLEASE DO IT IN JAVA**

Assignment 7.1 [45 points]

This program is broken down into two phases for your convenience only. Please turn in only your final product.

Phase 1:Write a program that draws a rocket on the screen. Here's what the rocket should look like:

 * * * * * ***** * * * * * * * * ***** ***** * * * * * * * * ***** * * * * * 

Your main method in phase 1 must look like this:

 public static void main(String[] args) { drawCone(); drawBox(); drawBox(); drawCone(); } 

You may simply use three println() statements (no loops are necessary) in your drawCone() method. For your drawBox() method, you must use the drawHorizontalLine(), draw2VerticalLines(), and drawOneRow() methods exactly as they appear in lesson 6. For phase 1 you'll be using the versions from lesson 6.3

Phase 2:In this phase you will allow the user to specify three things:

the height of each stage

the width of each stage

how many stages in the rocket

[A "stage" in your rocket is one rectangle. The example rocket above has a stage-height of 6, a stage-width of 5, and the number of stages is 2.]

Your main method in phase 2 must look like this:

 public static void main(String[] args) { <6 statements to prompt for and read the stage-height, stage-width, number of stages.> drawRocket(); } 

You must still use the drawHorizontalLine(), draw2VerticalLines(), and drawOneRow() methods exactly as they appear in lesson 6. For phase 2 you'll be using the versions from lesson 6.6.

Notice that if you run the program and choose a different width for your stages, the cone won't really fit correctly anymore. I won't make you fix this, but you can fix it for 5 points of extra credit if you like. However, I will not help you with the extra credit. In order to get the extra credit, the number of rows of your cone must be equal to the width of the stages divided by 2 (plus 1 for odd widths). If the stage width is an even number, your cone must have two stars in the top row instead of one. If you do this perfectly and use good decomposition in the process you'll get 5 extra credit points.

Please make sure to place a detailed comment above each of your method definitions, use good decomposition, and separate your methods with at least 6 blank lines. I suggest that now would be a good time to reread the Style Conventions section of the Syllabus.

Assignment 7.2 [40 points]

Create a class MyMath with a static method isPerfect() and a static method isPrime(). Each method has an int parameter and returns a boolean value. (A perfect number is a number that is equal to the sum of its divisors, not including itself. For example, 6 is a perfect number, because its divisors are 1, 2, and 3, and 1 + 2 + 3 = 6.) In a second file, create an application MyMathTest that displays a menu allowing the user to choose whether to display the prime numbers 1-1000, display the perfect numbers 1-10,000, or quit. Be sure to clearly label the output. Output the numbers 10 to a line.

Submit Your Work

Name your three source code files A7_1.java, MyMath.java, and MyMathTest.java. Execute each program and copy/paste the output into the bottom of the corresponding source code file, making it into a comment. Use the Assignment Submission link to submit the source files. When you submit your assignment there will be a text field in which you can add a note to me (called a "comment", but don't confuse it with a Java comment). In this "comments" section of the submission page let me know whether the programs work as required.

Keep in mind that if your code does not compile you will receive a 0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

8.1 Explain what is meant by "margin of error" in point estimation.

Answered: 1 week ago