SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 305 Weeks Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 31 Oct 2017 My Price 10.00

Code an application that prompt the user to enter an integer.

Hello, I am currently working on an assignment as follows:

 

Code an application that prompt the user to enter an integer. The application will compute the factorial of the integer using recursion. This application must be supported by a GUI that implements major GUI elements (labels, text fields, buttons, event handlers, mouse handlers, etc.):

  • Your GUI must have the title "RECURSION"
  • Code a label titled 'Number:' followed with a text field to input an integer.
  • Code a label titled 'Factorial:' followed with a non-editable text field to output the factorial.
  • Code a button titled 'Submit': this button should trigger an error event if clicked before a number is entered by user
  • Code an even handler that will trigger an error-beep of your choice and red background color on the input if the input is not an integer.
  • Code an even handler that will trigger a correct-input-beep of your choice and green background if the input is correct.

Your program must be very modular and you must code the needed validation (i.e. validating input).

 

This is what I have so far:

 

package factorial;

 

import javafx.application.Application;

import javafx.geometry.Insets;

import javafx.stage.Stage;

import javafx.geometry.Pos;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.scene.control.TextField;

import javafx.scene.image.ImageView;

import javafx.scene.layout.BorderPane;

import javafx.scene.layout.HBox;

import javafx.scene.layout.Pane;

import javafx.scene.text.Text;

 

public class Factorial extends Application {

 protected Text text = new Text(50, 50, "Enter Integer");

 protected BorderPane getPane() {

  HBox paneForButtons = new HBox(20);

  Button submit = new Button("Submit"); 

  paneForButtons.getChildren().addAll(submit);

  paneForButtons.setAlignment(Pos.CENTER);

  paneForButtons.setStyle("-fx-border-color: green");

 

  BorderPane pane = new BorderPane();

  pane.setBottom(paneForButtons);

  Pane numberText = new Pane();

  numberText.getChildren().add(text);

  pane.setCenter(numberText);

  BorderPane numberField = new BorderPane();

  numberField.setPadding(new Insets(5, 5, 5, 5)); 

  numberField.setStyle("-fx-border-color: green");

  numberField.setLeft(new Label("Number"));

  TextField number = new TextField();

  number.setAlignment(Pos.BOTTOM_RIGHT);

  numberField.setCenter(number);

  pane.setTop(numberField);

  number.setOnAction(e -> text.setText(number.getText()));

  Pane factorialText = new Pane();

  factorialText.getChildren().add(text);

  pane.setCenter(factorialText);

  BorderPane factorialField = new BorderPane();

  factorialField.setPadding(new Insets(5, 5, 5, 5)); 

  factorialField.setStyle("-fx-border-color: green");

  factorialField.setLeft(new Label("Factorial"));

  TextField factorial = new TextField();

  factorial.setAlignment(Pos.BOTTOM_RIGHT);

  factorialField.setCenter(factorial);

  pane.setBottom(factorialField);

  // Set to non-editable(boolean error)factorialField.setEditable(false);//

 

  factorial.setOnAction(e -> text.setText(factorial.getText()));

 

  return pane;

 }

 @Override // Override the start method in the Application class

 public void start(Stage primaryStage) {

  Scene scene = new Scene(getPane(), 450, 200);

  primaryStage.setTitle("Recursion"); 

  primaryStage.setScene(scene); 

  primaryStage.show(); 

 }

 

 /**

  * The main method is only needed for the IDE with limited

  * JavaFX support. Not needed for running from the command line.

  */

 public static void main(String[] args) {

  launch(args);

 }

  }

Answers

(5)
Status NEW Posted 31 Oct 2017 12:10 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)