Question: Implement a Java program with a non-static draw method to display a bar chart. Bar lengths follow the integer inputs with a range between 0

Implement a Java program with a non-static draw method to display a bar chart. Bar lengths follow the integer inputs with a range between 0 and 100. The bars are drawn with different colors for different ranges. The colors for the ranges are: {orange: 1~20}, {gray: 21~40}, {yellow: 41~60}, {blue: 61~80}, and {red: 81~100}. An OK button is pressed to show the chart. The chart below shows a result of {15, 50, 88, 35, 75}. The bar chart will change size according to the window frame size.

These are the required codes to complete the program.

public void paint(Graphics g){ g.translate(x, y); g.drawLine(x1, y1, x2, y2); g.drawString(String, x, y); g.setColor(Color); g.fillRect(x, y, width, height); }
Frame Title 100 90 80 70 60 50 40 30 20 10 V1: 15 v2. 50 V3 88 v4: 35 V5: 75 OK v1 v2 V3 v4 v5 Frame Title 100 90 80 70 60 50 40 30 20 10 V1: 15 v2. 50 V3 88 v4: 35 V5: 75 OK v1 v2 V3 v4 v5

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!