Chapter 14 Assignment

1 answer below »
Assignment is in the word document


Chapter 14 Assignment
Answered Same DaySep 29, 2021

Answer To: Chapter 14 Assignment

Shivani answered on Oct 03 2021
156 Votes
Solution/14.13/PieChart.java
Solution/14.13/PieChart.java
/*********************************************************************************
* Question 14.13                                                                 *
*/
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.shape.Arc;
import jav
afx.scene.shape.ArcType;
import javafx.scene.paint.Color;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
import javafx.geometry.Insets;
public class PieChart extends Application 
{
    @Override // Override the start method in the Application class
    public void start(Stage primaryStage) 
    {
        // Create a pane
        Pane pane = new Pane();
        double[] scores = {20, 10, 30, 40};
        String[] grades = {"Projects", "Quizzies", "Midterm Exams", "Final Exams"};
        // Create four text objects
        Text t1 = new Text(110, 80,  grades[0] + " -- " + scores[0] + "%");
        Text t2 = new Text(80, 15,   grades[1] + " -- " + scores[1] + "%");
        Text t3 = new Text(5, 100,   grades[2] + " -- " + scores[2] + "%");
        Text t4 = new Text(100, 180, grades[3] + " -- " + scores[3] + "%");
        // Create four Arcs
        Arc pieArch1 = new Arc(100, 100, 80, 80, 0, 360 * (scores[0] / 100));
        pieArch1.setFill(Color.RED);
        pieArch1.setType(ArcType.ROUND);
        Arc pieArch2 = new Arc(100, 100, 80, 80, pieArch1.getStartAngle() + pieArch1.getLength(), 360 * (scores[1] / 100));
        pieArch2.setFill(Color.BLUE);
        pieArch2.setType(ArcType.ROUND);
        Arc pieArch3 = new Arc(100, 100, 80, 80, pieArch2.getStartAngle() + pieArch2.getLength(), 360 * (scores[2] / 100));
        pieArch3.setFill(Color.GREEN);
        pieArch3.setType(ArcType.ROUND);
        Arc pieArch4 = new Arc(100, 100, 80, 80, pieArch3.getStartAngle() + pieArch3.getLength(), 360 * (scores[3] / 100));
        pieArch4.setFill(Color.ORANGE);
        pieArch4.setType(ArcType.ROUND);
        pane.getChildren().addAll(pieArch1, pieArch2, pieArch3, pieArch4, t1, t2, t3, t4);
        // Create a Scene 
        Scene scene = new Scene(pane);
        primaryStage.setTitle("Pie Chart for overall grade in projects, quizzes, midterm exams and final exams");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
Solution/14.3/image/card/1.png
Solution/14.3/image/card/10.png
Solution/14.3/image/card/11.png
Solution/14.3/image/card/12.png
Solution/14.3/image/card/13.png
Solution/14.3/image/card/14.png
Solution/14.3/image/card/15.png
Solution/14.3/image/card/16.png
Solution/14.3/image/card/17.png
Solution/14.3/image/card/18.png
Solution/14.3/image/card/19.png
Solution/14.3/image/card/2.png
Solution/14.3/image/card/20.png
Solution/14.3/image/card/21.png
Solution/14.3/image/card/22.png
Solution/14.3/image/card/23.png
Solution/14.3/image/card/24.png
Solution/14.3/image/card/25.png
Solution/14.3/image/card/26.png
Solution/14.3/image/card/27.png
Solution/14.3/image/card/28.png
Solution/14.3/image/card/29.png
Solution/14.3/image/card/3.png
Solution/14.3/image/card/30.png
Solution/14.3/image/card/31.png
Solution/14.3/image/card/32.png
Solution/14.3/image/card/33.png
Solution/14.3/image/card/34.png
Solution/14.3/image/card/35.png
Solution/14.3/image/card/36.png
Solution/14.3/image/card/37.png
Solution/14.3/image/card/38.png
Solution/14.3/image/card/39.png
Solution/14.3/image/card/4.png
Solution/14.3/image/card/40.png
Solution/14.3/image/card/41.png
Solution/14.3/image/card/42.png
Solution/14.3/image/card/43.png
Solution/14.3/image/card/44.png
Solution/14.3/image/card/45.png...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here