Programming Assignment # 3

$24.99 $18.99

For this homework, you will write a program that draws the coordinate system and some geometric shapes on the console screen. Ask the user to choose one of the following shapes: Line Parabola Circle If the user chooses to draw a line, ask for the coefficients a and b that define the line on the…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

For this homework, you will write a program that draws the coordinate system and some geometric shapes on the console screen.

Ask the user to choose one of the following shapes:

  1. Line

  1. Parabola

  1. Circle

If the user chooses to draw a line, ask for the coefficients a and b that define the line on the coordinate system: y = ax + b

Similarly, for the parabola, ask for the coefficients a, b, c to define the parabola: y = ax2 + bx + c

Finally, for the circle, ask for the radius (r) and center (a,b) to define it: (x – a)2 + (y – b)2 = r2

After getting required parameters, draw the coordinate system on the console screen using and | characters, and draw the geometric shape using * character.

Both x and y values in the coordinate system should range at least in [-10,10]. You may draw a bigger coordinate system as it will look clearer. However, make sure that your coordinate system fits in the console screen.

Sample run of the program is as follows:

Which shape would you like to draw?

  1. Line

  2. Parabola

  3. Circle

  4. Exit

1

Line formula is y = ax + b

Please enter coefficients a and b:-1 3

* y

* |

* |

* |

* |

* |

*|

*

|*

| *

———-|–*——-x

| *

| *

| *

| *

| *

| *

| *

| *

|

|

|

Which shape would you like to draw?

  1. Line

  2. Parabola

  3. Circle

  4. Exit

3

Circle formula is (x-a)^2 + (y-b)^2 = r^2

Please enter center’s coordinates (a,b) and radius:3 4 5

y

|

*

*

*

*|

*

|

|

* |

*

|

|

*|

*

———-*—–*—-x

| *

|

|

|

|

|

|

|

|

|

|

Which shape would you like to draw?

  1. Line

  2. Parabola

  3. Circle

  4. Exit

2

Parabola formula is y = ax^2 + bx + c Please enter coefficients a, b and c:1 -6 2

y

*| *

|

|

|

|

|

|

* *

|

———-|———-x

|

|

|* *

|

|

| * *

| *

|

|

|

|

Which shape would you like to draw?

  1. Line

  2. Parabola

  3. Circle

  4. Exit

4

Important Notes:

  • Your program will be tested with an auto-grader. So it should take the input exactly the same in the example and it should print the output exactly the same in the example. Otherwise, your program may fail.

  • Your program should execute correctly for different test cases.

  • Please do not write any package name at the beginning of your code!

  • Send your questions to your TA, Zuhal Altuntaş (zuhal.altuntas@marmara.edu.tr).

Submission Instructions

Please zip and submit all your files using the filename YourNumberHW3.zip (ex: 150713852HW3.zip) to the Canvas system (under the Assignments tab). Your zip file should contain the followings:

  1. Java source code (HW3_150713852.java)

  1. Java class file (HW3_150713852.class)

Notes:

  1. Write a comment at the beginning of each program to explain the purpose of the program. Write your name and student ID as a comment. Include necessary comments to explain your actions. Comments are very important for this homework.

  1. Select meaningful names for your variables.

  1. You are allowed to use the materials that you have learned in lectures & labs.

  1. Do not use the things that you did not learn in the course.

  1. Each student should submit his/her own homework. You can discuss with your peers about the homework but you are not allowed to exchange code or pseudocode. This also applies to material found on the web. Should some submitted homework assignments be identical or suspected to be identical, all involved parties will get a grade of ZERO from all homework. In case of any forms of cheating or copying, both giver and receiver are equally culpable and suffer equal penalties.

  1. No late submission will be accepted.

Programming Assignment # 3
$24.99 $18.99