it to create a class Student that includes four properties: an id (type Integer), a name (type String), a Major (type String) and a Grade (type Double). Use class Student to create objects (using buttonAdd) that will be read from the TextFields then save it into an ArrayList. Perform the following queries on the ArrayList of Student objects and show the results on the listViewStudents (Hint: add buttons as needed): d) Use lambdas and streams to calculate the total average of all Students grades, then show the result.   1.     Ch3HW;   import javafx.application.Application;   import javafx.fxml.FXMLLoader;   import javafx.scene.Parent;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Update it to create a class Student that includes four properties: an id (type Integer), a name (type String), a Major (type String) and a Grade (type Double). Use class Student to create objects (using buttonAdd) that will be read from the TextFields then save it into an ArrayList. Perform the following queries on the ArrayList of Student objects and show the results on the listViewStudents (Hint: add buttons as needed):

d) Use lambdas and streams to calculate the total average of all Students grades, then show the result.

 

1.  
  Ch3HW;
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  public class MainApp extends Application{
  @Override
  publicvoidstart(StageprimaryStage) throwsException {
  FXMLLoader loader =newFXMLLoader(getClass().getResource("StudentScreen.fxml"));
  Parent parent = loader.load();
  Scene scene =newScene(parent);
  primaryStage.setScene(scene);
  primaryStage.setTitle("Student Processing Screen");
  primaryStage.show();
  }
  publicstaticvoidmain(String[] args) {
  launch(args);
  }
  }
2.  
  <?xml version="1.0" encoding="UTF-8"?>
  <?import javafx.geometry.*?>
  <?import javafx.scene.effect.*?>
  <?import java.lang.*?>
  <?import java.util.*?>
  <?import javafx.scene.*?>
  <?import javafx.scene.control.*?>
  <?import javafx.scene.layout.*?>
  <FlowPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-font-size: 14; -fx-font-weight: bold;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Ch3HW.StudentScreenController">
  <children>
  <VBox alignment="CENTER" prefHeight="395.0" prefWidth="602.0">
  <children>
  <HBox alignment="CENTER" prefHeight="321.0" prefWidth="602.0" spacing="15.0">
  <children>
  <GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="141.0" prefWidth="239.0" vgap="10.0">
  <columnConstraints>
  <ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" maxWidth="142.0" minWidth="10.0" prefWidth="52.0" />
  <ColumnConstraints hgrow="SOMETIMES" maxWidth="188.0" minWidth="10.0" prefWidth="177.0" />
  </columnConstraints>
  <rowConstraints>
  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
  </rowConstraints>
  <children>
  <Label text="ID:" />
  <Label text="Name:" GridPane.rowIndex="1" />
  <Label text="Major:" GridPane.rowIndex="2" />
  <Label text="Grade:" GridPane.rowIndex="3" />
  <TextField fx:id="textFieldID" prefHeight="25.0" prefWidth="171.0" GridPane.columnIndex="1" />
  <TextField fx:id="textFieldName" prefHeight="25.0" prefWidth="145.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
  <TextField fx:id="textFieldMajor" GridPane.columnIndex="1" GridPane.rowIndex="2" />
  <TextField fx:id="textFieldGrade" GridPane.columnIndex="1" GridPane.rowIndex="3" />
  </children>
  </GridPane>
  <ListView fx:id="listViewStudents" prefHeight="321.0" prefWidth="302.0" style="-fx-font-family: monospaced;" />
  </children>
  </HBox>
  <HBox alignment="CENTER" prefHeight="74.0" prefWidth="602.0" spacing="15.0">
  <children>
  <Button fx:id="buttonAdd" mnemonicParsing="false" onAction="#buttonAddHandle" text="Add" />
  <Button fx:id="buttonClear" mnemonicParsing="false" onAction="#buttonClearHandle" text="Clear" />
  </children></HBox>
  </children>
  <effect>
  <InnerShadow choke="0.38" color="CORAL" height="85.5" radius="43.175" width="89.2" />
  </effect>
  <padding>
  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
  </padding>
  </VBox>
  </children>
  </FlowPane>
3.  
  package Ch3HW;
  import java.net.URL;
  import java.util.ResourceBundle;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.Button;
  import javafx.scene.control.ListView;
  import javafx.scene.control.TextField;
  /*** FXML Controller class*/
  public class StudentScreenController implements Initializable {
  @FXML
  privateTextField textFieldID;
  @FXML
  privateTextField textFieldName;
  @FXML
  privateTextField textFieldMajor;
  @FXML
  privateTextField textFieldGrade;
  @FXML
  privateListView<String> listViewStudents;
  @FXML
  privateButton buttonAdd;
  @FXML
  privateButton buttonClear;
  /*** Initializes the controller class.*/
  @Override
  publicvoidinitialize(URLurl, ResourceBundlerb) {
  // This is just a intitial data
  listViewStudents.getItems()
  .add(String.format("%-5s %-10s %-7s %8.2f", "111", "Ahmad", "CS", 93.2));
  listViewStudents.getItems()
  .add(String.format("%-5s %-10s %-7s %8.2f","123", "Marwa", "EDUC", 87.9));
  }
  @FXML
  privatevoidbuttonAddHandle(ActionEventevent) {
  }
  @FXML
  privatevoidbuttonClearHandle(ActionEventevent) {
  }
  }

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY