Initial Commit
This commit is contained in:
8
Source Code/Assignment9/.idea/.gitignore
generated
vendored
Normal file
8
Source Code/Assignment9/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../../:\ProgrammingProjects\JavaProjects\JavaYear1\Assignment9\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
25
Source Code/Assignment9/.idea/codeStyles/Project.xml
generated
Normal file
25
Source Code/Assignment9/.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,25 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
Source Code/Assignment9/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
Source Code/Assignment9/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
6
Source Code/Assignment9/.idea/discord.xml
generated
Normal file
6
Source Code/Assignment9/.idea/discord.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT" />
|
||||
</component>
|
||||
</project>
|
6
Source Code/Assignment9/.idea/misc.xml
generated
Normal file
6
Source Code/Assignment9/.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Source Code/Assignment9/.idea/modules.xml
generated
Normal file
8
Source Code/Assignment9/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Assignment9.iml" filepath="$PROJECT_DIR$/Assignment9.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
11
Source Code/Assignment9/Assignment9.iml
Normal file
11
Source Code/Assignment9/Assignment9.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
106
Source Code/Assignment9/src/GPACalculator.java
Normal file
106
Source Code/Assignment9/src/GPACalculator.java
Normal file
@ -0,0 +1,106 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class GPACalculator extends Application {
|
||||
FlowPane flowPane = new FlowPane();
|
||||
Text textPointsForCourse = new Text("Welcome to my GPA Calculator!");
|
||||
Text textCumulativeGPA = new Text("Enter your 1ˢᵗ grade and credit hrs.");
|
||||
TextField textFieldCLG = new TextField("");
|
||||
TextField textFieldCCH = new TextField("");
|
||||
Text textCLG = new Text("Course letter grade:");
|
||||
Text textCCH = new Text("Course Credit hours:");
|
||||
Button buttonAddGPA = new Button("Add to GPA");
|
||||
Button buttonClearGPA = new Button("Clear GPA");
|
||||
double GPA;
|
||||
double totalCreditHours;
|
||||
double totalGradePoints;
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
primaryStage.setTitle("GPA Calculator");
|
||||
flowPane.setPadding(new Insets(10, 10, 10, 10));
|
||||
flowPane.setHgap(10);
|
||||
flowPane.setVgap(10);
|
||||
flowPane.setAlignment(Pos.CENTER);
|
||||
|
||||
buttonAddGPA.setOnAction(this::AddGPA);
|
||||
buttonClearGPA.setOnAction(this::ClearGPA);
|
||||
|
||||
textFieldCCH.setPrefWidth(50);
|
||||
textFieldCCH.setOnAction(this::AddGPA);
|
||||
textFieldCLG.setPrefWidth(50);
|
||||
textFieldCLG.setOnAction(actionEvent -> textFieldCCH.requestFocus());
|
||||
|
||||
flowPane.getChildren().addAll(
|
||||
textCLG, textFieldCLG,
|
||||
textCCH, textFieldCCH,
|
||||
buttonAddGPA, buttonClearGPA,
|
||||
textPointsForCourse,
|
||||
textCumulativeGPA);
|
||||
|
||||
primaryStage.setScene(new Scene(flowPane, 210, 190));
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
private void ClearGPA(ActionEvent actionEvent) {
|
||||
textCumulativeGPA.setText("Enter your 1ˢᵗ grade and credit hrs.");
|
||||
textPointsForCourse.setText("Totals have been reset");
|
||||
textFieldCCH.setText("");
|
||||
textFieldCLG.setText("");
|
||||
totalCreditHours = 0;
|
||||
totalGradePoints= 0;
|
||||
GPA = 0;
|
||||
}
|
||||
private void AddGPA(ActionEvent actionEvent) {
|
||||
double creditHours = Double.parseDouble(textFieldCCH.getText());
|
||||
double gradePoints = 0;
|
||||
String letterGrade = textFieldCLG.getText();
|
||||
switch (letterGrade.toUpperCase()) {
|
||||
case "A+":
|
||||
gradePoints = 4.3*creditHours; break;
|
||||
case "A":
|
||||
gradePoints = 4.0*creditHours; break;
|
||||
case "A-":
|
||||
gradePoints = 3.7*creditHours; break;
|
||||
case "B+":
|
||||
gradePoints = 3.3*creditHours; break;
|
||||
case "B":
|
||||
gradePoints = 3.0*creditHours; break;
|
||||
case "B-":
|
||||
gradePoints = 2.7*creditHours; break;
|
||||
case "C+":
|
||||
gradePoints = 2.3*creditHours; break;
|
||||
case "C":
|
||||
gradePoints = 2.0*creditHours; break;
|
||||
case "D":
|
||||
gradePoints = 1.0*creditHours; break;
|
||||
case "F":
|
||||
case "WF":
|
||||
gradePoints = 0.0; break;
|
||||
default:
|
||||
textPointsForCourse.setText("Invalid Grade - GPA not changed");
|
||||
break;
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
textPointsForCourse.setText("Points for this course: " + df.format(gradePoints));
|
||||
totalCreditHours = totalCreditHours + Double.parseDouble(textFieldCCH.getText());
|
||||
totalGradePoints = totalGradePoints + gradePoints;
|
||||
GPA = totalGradePoints/totalCreditHours;
|
||||
textCumulativeGPA.setText("Your cumulative GPA is: " + df.format(GPA));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user