import javafx.application.Application; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JButton;...

1 answer below »
some m/c questions debug , coding questions


import javafx.application.Application; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextArea; import javax.swing.JTextField; public class Main { JLabel l1,l2,l3,l4; JTextField t1,t2,t3; JRadioButton r1,r2,r3; JButton Calculate; JTextArea all; Main(){ l1 = new JLabel("Invested Amount"); t1=new JTextField(); l2 = new JLabel("Rate of Interest"); t2=new JTextField(); l3 = new JLabel("Investment Years"); t3=new JTextField(); r1 = new JRadioButton ("Compounded Yearly"); r2 = new JRadioButton ("Compounded Half-Yearly "); r3 = new JRadioButton ("Compounded Quarterly"); l4 = new JLabel("Frequency of Interest"); ButtonGroup bg=new ButtonGroup(); bg.add(r1); bg.add(r2); bg.add(r3); Calculate = new JButton("Calculate"); Calculate.addActionListener(this); JPanel p1 = new JPanel(); p1.setLayout(new GridLayout(3,2)); p1.add(l1); p1.add(t1); p1.add(l2); p1.add(t2); p1.add(l3); p1.add(t3); p1.add(l4); JPanel p2 = new JPanel(); p2.setLayout(new GridLayout(5,1)); p2.add(l4); p2.add(r1); p2.add(r2); p2.add(r3); p2.add(Calculate); JPanel main = new JPanel(); main.setLayout(new GridLayout(3,1)); all = new JTextArea(); main.add(p1); main.add(p2); main.add(all); setTitle("Compoand Interest Calculator"); add(main); pack(); setVisible(true); setSize(1000,1000); setLayout(null); } public static void main(String[] args) { new Main(); } @Override public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("Calculate")) { int p = Integer.parseInt(t1.getText()); double r = Double.parseDouble(t2.getText()); int t = Integer.parseInt(t3.getText()); int n = 0; if(r1.isSelected()) n = 1; if(r2.isSelected()) n = 2; if(r3.isSelected()) n = 3; Interest in = new Interest(p, r, n, t); double interest = in.calculateInterest(); in.setI(interest); all.setText(in.display()); } } } import javafx.application.Application; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.Math; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextArea; import javax.swing.JTextField; class Interest{ private int P; private double r; private double I; private int n; private int t; public Interest(int p, double r, int n, int t) { this.P = p; this.r = r; this.n = n; this.t = t; } public void setP(int p) { P = p; } public void setR(double r) { this.r = r; } public void setI(double i) { I = i; } public void setN(int n) { this.n = n; } public void setT(int t) { this.t = t; } double calculateInterest() { double interest = (P * Math.pow((1 + ((r / 100)/ n)), n * t)) - P; return interest; } String display() { double total = P + I; return "Prinicple Amount is : " + P + "\n Total Interest Earned is : " + I + "\n Total Amount is : " + total; } } import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.RadioButton; import javafx.scene.control.TextField; import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.text.Text; import javafx.stage.Stage; public class Fun extends Application { Button leftButton, rightButton; HBox color, messagebox; RadioButton red, yellow, black, orange, green; ToggleGroup colorGroup; BorderPane borderPane; Text message; public void start(Stage stage) { stage.setTitle("Programming is fun"); red = new RadioButton("Red"); yellow = new RadioButton("Yellow"); black = new RadioButton("Black"); orange = new RadioButton("Orange"); green = new RadioButton("Green"); colorGroup = new ToggleGroup(); red.setToggleGroup(colorGroup); yellow.setToggleGroup(colorGroup);
Answered 5 days AfterAug 11, 2021

Answer To: import javafx.application.Application; import java.awt.GridLayout; import...

Swapnil answered on Aug 16 2021
145 Votes
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene
.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Cart extends Application {

private String[] items = {"Potato", "Egg", "Chicken", "Milk", "Bread"};
private VBox centerPane;
private TextArea output;

@Override
public void start(Stage primaryStage) {
BorderPane root = new BorderPane();
Scene scene = new Scene(root,600,500);

centerPane = new VBox(20);
centerPane.setPadding(new Insets(20, 20,20, 20));
centerPane.setAlignment(Pos.CENTER);
root.setCenter(centerPane);



output = new TextArea();
output.setEditable(false);
HBox outputpane = new HBox(10, output);
outputpane.setAlignment(Pos.CENTER);
outputpane.setPadding(new Insets(25, 25, 25, 25));
centerPane.getChildren().add(output);


root.setBottom(outputpane);
primaryStage.setTitle("CART");
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setOnAction(setTitle("CART"));
primaryStage.setOnAction(setScene(scene));
primaryStage.setOnAction(setScene(scene));
primaryStage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
void addToCart()
    {
        String pName;
        int found=0;
    
        System.out.println("Enter Product/Item Name :: ");
            pName=s1.next();
            
            Iterator i=a1.iterator();
            
            Set s=hm.entrySet();
            Iterator i1=s.iterator();
            
            
            while(i.hasNext())
            {
                Product...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here