Question: Write a JES function that allows the user to add an arbitrary number of lines on to an empty picture object. Each line must start

Write a JES function that allows the user to add an arbitrary number of lines on to an empty picture object. Each line must start from user specified x and y coordinates and finish at the center of the picture. After each line is added and displayed, the user must be asked if they wish to add another line. You must repeat this process until the user decides to stop. Finally, the number of lines added must be displayed. More specifically: 1. Allow the user to create an empty picture object based on a width and a height as entered via the keyboard. These inputs must be validated (see point #5 below). 2. For each line, allow the user to enter the 2 separate inputs (x1 and y1) and use the existing addLine(picture,x1,y1,x2,y2) function. These inputs must be validated (see point #5 below). The values of x2 and y2 will need to be calculated so that one side of the line is placed in the center of the image (Note: integer divisions rounding is acceptable). 3. Ask the user if they wish to add another line onto the picture and repeat from step 2, as necessary. Only while loops should be used, if necessary. The break or return statement must not be used to stop the loop. 4. Finally, print the total number of lines added. 5. Restrictions on input validation: Use only requestInteger for number inputs. If a user input is invalid, they must be asked to re-enter that value until they enter a correct value (error messages must be shown as appropriate). If an input is invalid, you must ensure that correct input is taken before taking different inputs. You must not use the break statement. Any upper and/or lower limits should be based on what is code-wise valid (i.e. they must not based on arbitrary values chosen by the programmer).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!