I want to update this JAVA program to : Exit cleanly, and change the pie chart to circle rather than an oval, and provide a separate driver please and thank you
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.Scanner;
import javax.swing.JComponent;
import javax.swing.JFrame;
// class to store the value and color mapping of the
// pie segment(slices)
class Segment {
double value;
Color color;
// constructor
public Segment(double value, Color color) {
this.value = value;
this.color = color;
}
}
class pieChartComponent extends JComponent {
private static final long serialVersionUID = 1L;
Segment[] Segments;
// Parameterized constructor
// create 4 segments of the pie chart
pieChartComponent(int v1, int v2, int v3, int v4) {
Segments = new Segment[] { new Segment(v1, Color.black), new
Segment(v2, Color.green), new Segment(v3, Color.yellow),
new Segment(v4, Color.red) };
}
// function responsible for calling the worker method
drawPie
public void paint(Graphics g) {
drawPie((Graphics2D) g, getBounds(), Segments);
}
// worker function for creating the percentage wise slices of
the pie chart
void drawPie(Graphics2D g, Rectangle area, Segment[] Segments)
{
double total = 0.0D;
// fin the total of the all the inputs provided by the user
for (int i = 0; i < Segments.length; i++) {
total += Segments[i].value;
}
// Initialization
double curValue = 0.0D;
int strtAngle = 0;
// iterate till all the segments are covered
for (int i = 0; i < Segments.length; i++) {
// compute start angle, with percentage
strtAngle = (int) (curValue * 360 / total);
// find the area angle of the segment
int arcAngle = (int) (Segments[i].value * 360 / total);
g.setColor(Segments[i].color);
g.fillArc(area.x, area.y, area.width, area.height, strtAngle,
arcAngle);
curValue += Segments[i].value;
}
}
}
public class Graphic_Pie2D {
public static void main(String[] argv) {
System.out.println("Pleae provide 4 values, to create the pie
chart");
Scanner input = new Scanner(System.in);
int v1, v2, v3, v4;
v1 = input.nextInt();
v2 = input.nextInt();
v3 = input.nextInt();
v4 = input.nextInt();
// create a JFrame with title
JFrame frame = new JFrame("Pie Chart");
frame.getContentPane().add(new
pieChartComponent(v1,v2,v3,v4));
frame.setSize(500, 300);
frame.setVisible(true);
}
}
here's the assignment for reference :
Pie chart: prompt the user (at the command line) for 4 positive integers, then draw a pie chart in a window. Convert the numbers to percentages of the numbers’ total sum; color each segment differently; use Arc2D. No text fields (other than the window title) are required. Provide a driver in a separate source file to test your class.
In: Computer Science
Chapter 6: Use a list to store the players
Update the program in python so that it allows you to store the players for the starting lineup. This
should include the player’s name, position, at bats, and hits. In addition, the program
should calculate the player’s batting average from at bats and hits.
Console
================================================================
Baseball Team Manager
MENU OPTIONS
1 – Display lineup
2 – Add player
3 – Remove player
4 – Move player
5 – Edit player position
6 – Edit player stats
7 - Exit program
POSITIONS
C, 1B, 2B, 3B, SS, LF, CF, RF, P
================================================================
Menu option: 2
Name: Mike
Position: C
At bats: 0
Hits: 0
Mike was added.
Menu option: 1
Player POS AB H AVG
----------------------------------------------------------------
1 Joe P 10 2 0.2
2 Tom SS 11 4 0.364
3 Ben 3B 0 0 0.0
4 Mike C 0 0 0.0
Menu option: 6
Lineup number: 4
You selected Mike AB=0 H=0
At bats: 4
Hits: 1
Mike was updated.
Menu option: 4
Current lineup number: 4
Mike was selected.
New lineup number: 1
Mike was moved.
Menu option: 7
Bye!
Specifications
Use a list of lists to store each player in the lineup.
Use a tuple to store all valid positions (C, 1B, 2B, etc).
Make sure that the user’s position entries are valid.
In: Computer Science
Chapter 6: Use a list to store the players
In Python, Update the program so that it allows you to store the players for the starting lineup. This
should include the player’s name, position, at bats, and hits. In addition, the program
should calculate the player’s batting average from at bats and hits.
Console
================================================================
Baseball Team Manager
MENU OPTIONS
1 – Display lineup
2 – Add player
3 – Remove player
4 – Move player
5 – Edit player position
6 – Edit player stats
7 - Exit program
POSITIONS
C, 1B, 2B, 3B, SS, LF, CF, RF, P
================================================================
Menu option: 2
Name: Mike
Position: C
At bats: 0
Hits: 0
Mike was added.
Menu option: 1
Player POS AB H AVG
----------------------------------------------------------------
1 Joe P 10 2 0.2
2 Tom SS 11 4 0.364
3 Ben 3B 0 0 0.0
4 Mike C 0 0 0.0
Menu option: 6
Lineup number: 4
You selected Mike AB=0 H=0
At bats: 4
Hits: 1
Mike was updated.
Menu option: 4
Current lineup number: 4
Mike was selected.
New lineup number: 1
Mike was moved.
Menu option: 7
Bye!
Specifications
Use a list of lists to store each player in the lineup.
Use a tuple to store all valid positions (C, 1B, 2B, etc).
Make sure that the user’s position entries are valid.
In: Computer Science
In: Finance
You need a particular piece of equipment for your production process. An equipment-leasing company has offered to lease the equipment to you for $ 10,100 per year if you sign a guaranteed 5-year lease (the lease is paid at the end of eachyear). The company would also maintain the equipment for you as part of the lease. Alternatively, you could buy and maintain the equipment yourself. The cash flows from doing so are listed below(the equipment has an economic life of 5 years). If your discount rate is 6.6%, what should you do?
Year 0 = -$40,700
Year 1: -$2000
Year 2: -$2000
Year 3: -$2000
Year 4: -$2000
Year 5: -$2000
a.) The net present value of the leasing alternative is:
b.) The net present value of the buying alternative is:
In: Finance
1. Consider the following data for the “home” country of Afar (whose currency is the Afarian pound, £); the “foreign” currency is the U.S. dollar ($):
2000 2006
E £20/$ £22/$
Phome 100 140
Pforeign 100 110
In: Economics
Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.29 million and create incremental cash flows of $632,693.00 each year for the next five years. The cost of capital is 11.03%. What is the net present value of the J-Mix 2000?
Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.56 million and create incremental cash flows of $443,493.00 each year for the next five years. The cost of capital is 10.74%. What is the internal rate of return for the J-Mix 2000?
Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.67 million and create incremental cash flows of $639,849.00 each year for the next five years. The cost of capital is 8.28%. What is the profitability index for the J-Mix 2000?
Please answer all 3:)
In: Accounting
#31 Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.38 million and create incremental cash flows of $877,269.00 each year for the next five years. The cost of capital is 11.18%. What is the net present value of the J-Mix 2000?
#32 Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.95 million and create incremental cash flows of $547,959.00 each year for the next five years. The cost of capital is 11.75%. What is the internal rate of return for the J-Mix 2000?
#33 Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.93 million and create incremental cash flows of $590,625.00 each year for the next five years. The cost of capital is 10.39%. What is the profitability index for the J-Mix 2000?
In: Finance
1.Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.72 million and create incremental cash flows of $563,361.00 each year for the next five years. The cost of capital is 9.95%. What is the net present value of the J-Mix 2000?
2.Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.72 million and create incremental cash flows of $566,982.00 each year for the next five years. The cost of capital is 8.44%. What is the internal rate of return for the J-Mix 2000?
3.Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.73 million and create incremental cash flows of $500,066.00 each year for the next five years. The cost of capital is 10.74%. What is the profitability index for the J-Mix 2000?
In: Finance
Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.33 million and create incremental cash flows of $861,681.00 each year for the next five years. The cost of capital is 8.75%. What is the net present value of the J-Mix 2000?
Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.86 million and create incremental cash flows of $571,580.00 each year for the next five years. The cost of capital is 9.90%. What is the internal rate of return for the J-Mix 2000?
Caspian Sea Drinks is considering buying the J-Mix 2000. It will allow them to make and sell more product. The machine cost $1.79 million and create incremental cash flows of $641,169.00 each year for the next five years. The cost of capital is 11.73%. What is the profitability index for the J-Mix 2000?
In: Finance