Question
Topic: Graphics Description: Write a Java program that inputs sales amounts from five regions of a company and displays a pie chart as a percentage
Topic: Graphics
Description:
Write a Java program that inputs sales amounts from five regions of a company and displays a pie chart as a percentage of sales.
Implementation:
Write the following classes:
class PieChart
Write a class PieChart that extends JFrame and provides the following:
Five private int variables for holding sales amounts from five regions: North, South, East, West, and Midwest.
A public constructor with five parameters that initializes the sales amounts for the five regions.
The method paint() that overrides the paint method in the parent class. In the paint method, convert the sales amounts into percentages and display them as a pie chart as shown below. Also show a legend at the bottom of the pie chart.
class TestPieChart
Write a class TestPieChart that contains the method main(). In the main method, provide the following:
Prompt the user to input sales amounts for the five regions.
Create a PieChart object and pass it the sales amounts of the five regions.
Set the size of the PieChart object to 500,500.
Set the PieChart object to be visible.
Implementation
In the class PieChart that extends JFrame, provide the paint method as shown below. In the paint method, use the Graphics object to do the drawing.
public void paint (Graphics g)
{
}
Test Data
Use the following test data in millions of dollars:
North: 20
South: 25
East: 15
West: 30
Midwest 10
North 20.0 South-250 East-15.0 West-30.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started