May 11, 2023

Brute Force Techniques I

This is a description

The Welcome Message

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class Main extends Application {

    public void start(Stage primaryStage) {
        Label label = new Label("Welcome to JavaFX programming");
        label.setTextFill(Color.MAGENTA);

        FlowPane root = new FlowPane();
        root.getChildren().add(label);
        root.setHgap(10);
        root.setVgap(10);

        Scene scene = new Scene(root, 500, 200);
        primaryStage.setTitle("This is the first JavaFX Application");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

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

Untitled

Multiplication Tables

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;

public class Main extends Application {
    public void start(Stage primaryStage) {
        Label label = new Label("Enter a number:");
        TextField textField = new TextField();
        Button showTableButton = new Button("Show Table");

        FlowPane root = new FlowPane();
        root.setAlignment(Pos.CENTER);
        root.setHgap(10);
        root.setVgap(10);

        Label resultLabel = new Label("");
        VBox resultBox = new VBox();
        resultBox.setAlignment(Pos.CENTER);

        root.getChildren().addAll(label, textField, showTableButton, resultBox);

        showTableButton.setOnAction(event -> {
            try {
                int number = Integer.parseInt(textField.getText());
                String result = generateMultiplicationTable(number);
                resultLabel.setText(result);
            } catch (NumberFormatException e) {
                resultLabel.setText("Please enter a valid integer.");
            }
        });

        resultBox.getChildren().add(resultLabel);

        Scene scene = new Scene(root, 350, 400);
        primaryStage.setTitle("Multiplication Table Application");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    private String generateMultiplicationTable(int number) {
        StringBuilder table = new StringBuilder();

        table.append("Multiplication Table for " + number + ":\n");

        for (int i = 1; i <= 10; i++) {
            table.append(number + " x " + i + " = " + number * i + "\n");
        }

        return table.toString();
    }

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

Untitled

Welcome Window

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Main extends Application {
    public void start(Stage primaryStage) {
        Label usernameLabel = new Label("Username:");
        Label passwordLabel = new Label("Password:");
        TextField usernameTextField = new TextField();
        PasswordField passwordField = new PasswordField();
        Button signInButton = new Button("Sign in");
        Text welcomeText = new Text();

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

        root.add(usernameLabel, 0, 0);
        root.add(usernameTextField, 1, 0);
        root.add(passwordLabel, 0, 1);
        root.add(passwordField, 1, 1);
        root.add(signInButton, 1, 2);
        root.add(welcomeText, 1, 3);

        signInButton.setOnAction(event -> {
            String username = usernameTextField.getText();
            String password = passwordField.getText();
            if (!username.isEmpty() && !password.isEmpty()) {
                welcomeText.setText("Welcome " + username);
            } else {
                welcomeText.setText("Please enter both username and password.");
            }
        });

        Scene scene = new Scene(root, 300, 200);
        primaryStage.setTitle("JavaFX Welcome");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

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

Untitled

Employee Attributes

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

class Employee {
    String name;
    int empID;
    String designation;
    double basicPay;
    double DA;
    double HRA;
    double PF;
    double LIC;
    double netSalary;

    public Employee(String name, int empID, String designation, double basicPay) {
        this.name = name;
        this.empID = empID;
        this.designation = designation;
        this.basicPay = basicPay;
        this.DA = 0.4 * basicPay;
        this.HRA = 0.15 * basicPay;
        this.PF = 0.12 * basicPay;
        this.LIC = 0;
        this.netSalary = basicPay + DA + HRA - PF - LIC;
    }
}

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) {
        Employee employee = new Employee("John Doe", 101, "Manager", 50000.0);

        Label nameLabel = new Label("Name: " + employee.name);
        Label empIDLabel = new Label("Employee ID: " + employee.empID);
        Label designationLabel = new Label("Designation: " + employee.designation);
        Label basicPayLabel = new Label("Basic Pay: Ts." + employee.basicPay);
        Label DALabel = new Label("DA: Rs." + employee.DA);
        Label HRALabel = new Label("HRA: Rs." + employee.HRA);
        Label PFLabel = new Label("PF: Rs." + employee.PF);
        Label LICLabel = new Label("LIC: Rs." + employee.LIC);
        Label netSalaryLabel = new Label("Net Salary: Rs." + employee.netSalary);

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

        root.add(nameLabel, 0, 0);
        root.add(empIDLabel, 0, 1);
        root.add(designationLabel, 0, 2);
        root.add(basicPayLabel, 0, 3);
        root.add(DALabel, 0, 4);
        root.add(HRALabel, 0, 5);
        root.add(PFLabel, 0, 6);
        root.add(LICLabel, 0, 7);
        root.add(netSalaryLabel, 0, 8);

        Scene scene = new Scene(root, 300, 400);
        primaryStage.setTitle("Employee Information");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

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

Untitled