Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create applet that will draw a pie chart, you are given the values of pie slices as constants, you will also need to calculate

image text in transcribedimage text in transcribed

Create applet that will draw a pie chart, you are given the values of pie slices as constants, you will also need to calculate the total of the full pie, and then determine the percentage of each pie slice using the given values as well as the calculated pie total, all the percentage must be displayed in their respective pie slices. You will also need to display text with your student number, initials and surname at the end of the pie chart. Noete: Use NumberFormat perc = NumberFormat.getPercentInstance() to convert fraction percentage to a whole number percentage. EG 0.45 must be 45%, display formatted percentages in their pi slices, see figure. Note Sizes of pies must be declared as constant values Constant pie sizes are as follows BLUESIZE = 90 ORANGESIZE=130 GREENSIZE=110 REDSIZE=30 Complex Shape Class: PiChart Class Purpose: Display Pie Chart as in figure 1,2 and 3 at the graphics context. 1 Class Specifications: Store the x,y coordinates and length of the full pie must be a 200 x 200 pixels. Code a parameterized constructor that takes the x,y coordinates, the length of pie must be included in the constructor as default values. Code the necessary mutator(set) and accessor(get) methods of the x, y coordinates attributes. Also declare pie sizes as constants in this class, see above for given pie sizes. Code a method called drawPiChart() to display the PiChart as in Figure 1. The pie slices color must be per given sizes above. We prese Code a method called displayTextAndLine() to display Text with your details and a line. NAN Note: The string (text) must have your details instead of MS MNGOMA The text color must be cyan and have a font- Arial, bold and 20 in size w The line must be magenta in color and thickened to 8 pixels. Code a method called displayPi Percentages(), . This method must 1st calculate total of all pie sizes to make full pie. TA > It must also determine each pie slice percentage using given pie size velice and lated total ni values and calculated total pie. TL It must display formatted percentages in their respective pie slices Note: all pie percentages text must be white in color, the font of all percentages text must be Arial, bold and 20 in size and must be formatted correctly to percentage using NumberFormat as explain in a discription. Note: You can code the Font once, in the applet, and it will be applicable to all text(string) PiChart Applet Get the PiChart x and y coordinates from the user. Handle proper exception for any invalid input. Display the PiChart only without a string (text). See Figure1. If the user clicked the left mouse button, display the string (text) and line on the applet. Hint: call (invoke) correct method from PiChartClass If the user clicked the middle mouse button, display all percentages string (text) in their pie slices. Hint: call (invoke) correct method to do this from PiChartClass. Change the Applet size to 500 x 500 pixels Applet Viewer: vut/PiChatApplet.class Applet Applet started Fig1 Applet Viewer: vut/PiChartApplet.class Applet 36% 31% Applet started. 25% 8% Applet Viewen vut/PiChartApplet.class Applet END OF PIE CHART CREATED BY MS MNGOMA Applet started. fig2 END OF PIE CHART CREATED BY MS MNGOMA X fig3 X

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

Step: 3

blur-text-image

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

Introduction to Operations Research

Authors: Frederick S. Hillier, Gerald J. Lieberman

10th edition

978-0072535105, 72535105, 978-1259162985

More Books

Students also viewed these Programming questions

Question

Considering the discussion in Box

Answered: 1 week ago