Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

North 20.0 South-250 East-15.0 West-30.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

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

1. What is meant by Latitudes? 2. What is cartography ?

Answered: 1 week ago

Question

What is order of reaction? Explain with example?

Answered: 1 week ago