1.Problem Description Student information management system is used to input, display student information records. 1. The GUI interface for inputing ia designed as follows: The top part are the student imformation used to input student information and the bottom part are four buttonns, 2. each button meaning: 3. (2) Total: add java score and C++ score, and display the result 4. (3) Save: save student record into file named student.dat; 5. (4) Clear: set all fields on GUI to empty string: 6. (5) Close: close the window of GUI Student ID: Java Score: Note: Student Management System Student name: C++ Score: Sex Male Female

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
1.Problem Description
Student information management system is used to input, display student information records.
1. The GUI interface for inputing ia designed as follows: The top part are the student imformation used to input student information, and the bottom part are four buttonns,
2. each button meaning:
3. (2) Total: add java score and C++ score, and display the result;
4. (3) Save: save student record into file named student.dat;
5. (4) Clear: set all fields on GUI to empty string:
6. (5) Close: close the window of GUI
Student ID:
Java Score:
Note:
Total
Student ID: BC501
Java Score: 80
Note:
He study java hard.
Total
Student Management System
Student name:
C++ Score:
Save
C++ Score: 90.5
Student Management System
Student name: ALVIN CARM
Save
Total scores:
Clear
Sex
Clear
D E
Male Female
Close
Sex Male Female
Total scores: 170.5
Close
Transcribed Image Text:1.Problem Description Student information management system is used to input, display student information records. 1. The GUI interface for inputing ia designed as follows: The top part are the student imformation used to input student information, and the bottom part are four buttonns, 2. each button meaning: 3. (2) Total: add java score and C++ score, and display the result; 4. (3) Save: save student record into file named student.dat; 5. (4) Clear: set all fields on GUI to empty string: 6. (5) Close: close the window of GUI Student ID: Java Score: Note: Total Student ID: BC501 Java Score: 80 Note: He study java hard. Total Student Management System Student name: C++ Score: Save C++ Score: 90.5 Student Management System Student name: ALVIN CARM Save Total scores: Clear Sex Clear D E Male Female Close Sex Male Female Total scores: 170.5 Close
Expert Solution
Step 1

Step 1: Create StudentManagementApplication.java and below code.

package com.chegg.jun11a.javafx;

import java.io.FileWriter;
import java.io.IOException;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;

public class StudentManagementApplication extends Application {

	public static final String BLANK = "";

	public static final String OUTPUT_FILE_PATH = "C:\\Users\\bsayyad\\eclipse-workspace-unifier\\CheggSolutions-Jun-2021\\src\\main\\java\\com\\chegg\\jun11a\\javafx\\student.dat";

	@Override
	public void start(Stage stage) {
		stage.setTitle("Student Management System");

		GridPane grid = new GridPane();
		grid.setAlignment(Pos.CENTER);
		grid.setHgap(10);
		grid.setVgap(10);
		grid.setPadding(new Insets(25, 25, 25, 25));

		Label sceneTitle = new Label("Student Management System");
		sceneTitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 30));
		sceneTitle.setStyle("-fx-text-fill: #5933FF;");
		grid.add(sceneTitle, 2, 0, 2, 1);

		Label studentIdLabel = new Label("Student ID:");
		grid.add(studentIdLabel, 0, 1);

		TextField studentIdField = new TextField();
		grid.add(studentIdField, 1, 1);

		Label studentNameLabel = new Label("Student Name:");
		grid.add(studentNameLabel, 2, 1);

		TextField studentNameField = new TextField();
		grid.add(studentNameField, 3, 1);

		Label sexLabel = new Label("Sex");
		grid.add(sexLabel, 4, 1);

		RadioButton maleRb = new RadioButton("Male");
		RadioButton femaleRb = new RadioButton("Female");
		ToggleGroup sexGroup = new ToggleGroup();
		maleRb.setToggleGroup(sexGroup);
		femaleRb.setToggleGroup(sexGroup);
		HBox sexSelector = new HBox(10, maleRb, femaleRb);
		grid.add(sexSelector, 5, 1);

		Label javaScoreLabel = new Label("Java Score:");
		grid.add(javaScoreLabel, 0, 2);

		TextField javaScoreField = new TextField();
		grid.add(javaScoreField, 1, 2);

		Label cppScoreLabel = new Label("C++ Score:");
		grid.add(cppScoreLabel, 2, 2);

		TextField cppScoreField = new TextField();
		grid.add(cppScoreField, 3, 2);

		Label noteLabel = new Label("Note:");
		grid.add(noteLabel, 0, 3);

		TextField noteField = new TextField();
		grid.add(noteField, 0, 4, 6, 1);

		Label totalScoresLabel = new Label("Total Scores:");
		grid.add(totalScoresLabel, 4, 5);

		TextField totalScoreField = new TextField();
		totalScoreField.setEditable(false);
		grid.add(totalScoreField, 5, 5);

		Button totalButton = new Button("Total");
		totalButton.setPrefWidth(500);
		Button saveButton = new Button("Save");
		saveButton.setPrefWidth(500);
		Button clearButton = new Button("Clear");
		clearButton.setPrefWidth(500);
		Button closeButton = new Button("Close");
		closeButton.setPrefWidth(500);

		HBox hBoxDisplay = new HBox(totalButton, saveButton, clearButton, closeButton);
		grid.add(hBoxDisplay, 0, 6, 6, 1);

		totalButton.setOnAction(actionEvent -> {
			String studentId = studentIdField.getText();
			String studentName = studentNameField.getText();
			RadioButton sexSelection = (RadioButton) sexGroup.getSelectedToggle();
			String sex = (sexSelection == null) ? "" : sexSelection.getText();
			String javaScore = javaScoreField.getText();
			String cppScore = cppScoreField.getText();
			if (BLANK.equals(studentId) || BLANK.equals(studentName) || BLANK.equals(sex) || BLANK.equals(javaScore)
					|| BLANK.equals(cppScore)) {
				this.alert("Error", "Please enter all input values!", AlertType.ERROR);
				return;
			} else {
				double java = Double.parseDouble(javaScore);
				double cpp = Double.parseDouble(cppScore);
				double total = java + cpp;
				totalScoreField.setText(String.valueOf(total));
				if (java < cpp) {
					noteField.setText("Hey study Java hard.");
				} else {
					noteField.setText("Hey study C++ hard.");
				}
			}

		});

		saveButton.setOnAction(actionEvent -> {
			String studentId = studentIdField.getText();
			String studentName = studentNameField.getText();
			RadioButton sexSelection = (RadioButton) sexGroup.getSelectedToggle();
			String sex = sexSelection.getText();
			String javaScore = javaScoreField.getText();
			String cppScore = cppScoreField.getText();
			if (BLANK.equals(studentId) || BLANK.equals(studentName) || BLANK.equals(sex) || BLANK.equals(javaScore)
					|| BLANK.equals(cppScore)) {
				this.alert("Error", "Please enter all input values!", AlertType.ERROR);
				return;
			} else {
				double java = Double.parseDouble(javaScore);
				double cpp = Double.parseDouble(cppScore);
				double total = java + cpp;
				totalScoreField.setText(String.valueOf(total));

				try {
					FileWriter writer = new FileWriter(OUTPUT_FILE_PATH, true);
					writer.write(studentId + "," + studentName + "," + sex + "," + javaScore + "," + cppScore + ","
							+ total + "\n");
					writer.close();
					this.alert("Success", "Record saved successfully", AlertType.INFORMATION);
				} catch (IOException e) {
					e.printStackTrace();
				}

			}

		});

		clearButton.setOnAction(actionEvent -> {
			studentIdField.setText(BLANK);
			studentNameField.setText(BLANK);
			javaScoreField.setText(BLANK);
			cppScoreField.setText(BLANK);
			noteField.setText(BLANK);
			totalScoreField.setText(BLANK);
			sexGroup.getSelectedToggle().setSelected(false);
		});

		closeButton.setOnAction(actionEvent -> {
			System.exit(0);
		});

		Scene scene = new Scene(grid, 1050, 400);
		stage.setScene(scene);

		stage.show();
	}

	public void alert(String title, String message, AlertType alertType) {
		Alert alert = new Alert(alertType);
		alert.setTitle(title);
		alert.setHeaderText(null);
		alert.setContentText(message);
		alert.showAndWait();
	}

	public static void main(String[] args) {
		launch(args);
	}
}

Now run the above code. Below window will be opened.

Х
O eclipse-workspace-unifier - CheggSolutions-Jun-2021/src/main/java/com/chegg/jun11a/javafx/Student Management Application.

Now fill the data and click on Total button. Total score wil be calculated and based on score, note field will get updated.

Х
O eclipse-workspace-unifier - CheggSolutions-Jun-2021/src/main/java/com/chegg/jun11a/javafx/Student Management Application.

Now click on Save button.

Х
Q
usergroupPicke...
multiusersPick...
multiusersPick...
Student Manage... x student.dat
(x)=
Ju
Х
Х
val\com\\chegg\\jun11a

We can see the saved details in the file.

 

 

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education