Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could you help me seperate to 3 java class, base on the below coding? import jav

ID: 3721758 • Letter: C

Question

Could you help me seperate to 3 java class, base on the below coding?

import javax.swing.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
class Solution extends JFrame
{
JLabel LblRate; //Label for Interest Rate
JLabel LblYear; //Label for Number of Year
JLabel LblAmount; //Label for Loan Amount
JLabel LblMPayment; //Label for Monthly payment
JLabel LblTPayment; //Label for Total Payment
JTextField TxtRate; //TextFiled for interst
JTextField TxtYear; //TextFiled for Years
JTextField TxtAmount; //TextFiled for Loan amount
JTextField TxtMPayment; //TextFiled for Monthly Payment
JTextField TxtTPayment; //Textfield for Total Payment
JButton BtnCalculate; //Button to calculate
Container c;
public Solution()
{
//Initialize all components
c=getContentPane();
c.setLayout(null);
int w=150,h=20,col=30,row=5;
BtnCalculate = new JButton("Calculate"); BtnCalculate.setBounds(col+180,row+110,w-30,h);
LblRate = new JLabel(); LblRate.setText("Annual Interest Rate:"); LblRate.setBounds(col,row,w,h);
LblYear = new JLabel(); LblYear.setText("Number of Years:"); LblYear.setBounds(col,row+20,w,h);
LblAmount = new JLabel(); LblAmount.setText("Loan Amount"); LblAmount.setBounds(col,row+40,w,h);
LblMPayment = new JLabel(); LblMPayment.setText("Monthly Payment:"); LblMPayment.setBounds(col,row+60,w,h);
LblTPayment = new JLabel(); LblTPayment.setText("Total Payment:"); LblTPayment.setBounds(col,row+80,w,h);
TxtRate = new JTextField(); TxtRate.setBounds(col+150,row,w,h);
TxtYear = new JTextField(); TxtYear.setBounds(col+150,row+20,w,h);
TxtAmount = new JTextField(); TxtAmount.setBounds(col+150,row+40,w,h);
TxtMPayment = new JTextField(); TxtMPayment.setEditable(false); TxtMPayment.setBounds(col+150,row+60,w,h);
TxtTPayment = new JTextField(); TxtTPayment.setEditable(false); TxtTPayment.setBounds(col+150,row+80,w,h);
//Add all components to layout
c.add(LblRate);
c.add(TxtRate);
c.add(LblYear);
c.add(TxtYear);
c.add(LblAmount);
c.add(TxtAmount);
c.add(LblMPayment);
c.add(TxtMPayment);
c.add(LblTPayment);
c.add(TxtTPayment);
c.add(BtnCalculate);
BtnCalculate.addActionListener(new BtnClick());
setSize(400,250);
setTitle("Tax Calculation");
setVisible(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
private class BtnClick implements ActionListener
{
//Set action on calculate button click
public void actionPerformed(ActionEvent ae)
{
//Get values & calculate based on given formula
float interest = Float.parseFloat(TxtRate.getText());
interest*=0.01;
interest/=12;
float years = Float.parseFloat(TxtYear.getText());
years*=12;
float amount = Float.parseFloat(TxtAmount.getText());
float monthlyPayment = (interest*amount)/(1-(float)Math.pow((1+interest),-years));
//Print the result
String formatedValue = String.format("%.2f", monthlyPayment);
TxtMPayment.setText(formatedValue);
formatedValue = String.format("%.2f", (years*monthlyPayment));
TxtTPayment.setText(formatedValue);
}
}
//Main method to run the application
public static void main(String arg[])
{
Solution obj = new Solution();
}
}

Explanation / Answer

import javax.swing.*;

import java.io.*;

import java.util.*;

import java.awt.event.*;

import java.awt.*;

//***********************Class01***************************************

public class Class1{

public static void main(String arg[])

{

Class2 obj = new Class2();

}

}

//***********************Class02***************************************

class Class2 extends JFrame

{

JLabel LblRate; //Label for Interest Rate

JLabel LblYear; //Label for Number of Year

JLabel LblAmount; //Label for Loan Amount

JLabel LblMPayment; //Label for Monthly payment

JLabel LblTPayment; //Label for Total Payment

static JTextField TxtRate; //TextFiled for interst

static JTextField TxtYear; //TextFiled for Years

static JTextField TxtAmount; //TextFiled for Loan amount

static JTextField TxtMPayment; //TextFiled for Monthly Payment

static JTextField TxtTPayment; //Textfield for Total Payment

JButton BtnCalculate; //Button to calculate

Container c;

public Class2()

{

//Initialize all components

c=getContentPane();

c.setLayout(null);

int w=150,h=20,col=30,row=5;

BtnCalculate = new JButton("Calculate"); BtnCalculate.setBounds(col+180,row+110,w-30,h);

LblRate = new JLabel(); LblRate.setText("Annual Interest Rate:"); LblRate.setBounds(col,row,w,h);

LblYear = new JLabel(); LblYear.setText("Number of Years:"); LblYear.setBounds(col,row+20,w,h);

LblAmount = new JLabel(); LblAmount.setText("Loan Amount"); LblAmount.setBounds(col,row+40,w,h);

LblMPayment = new JLabel(); LblMPayment.setText("Monthly Payment:"); LblMPayment.setBounds(col,row+60,w,h);

LblTPayment = new JLabel(); LblTPayment.setText("Total Payment:"); LblTPayment.setBounds(col,row+80,w,h);

TxtRate = new JTextField(); TxtRate.setBounds(col+150,row,w,h);

TxtYear = new JTextField(); TxtYear.setBounds(col+150,row+20,w,h);

TxtAmount = new JTextField(); TxtAmount.setBounds(col+150,row+40,w,h);

TxtMPayment = new JTextField(); TxtMPayment.setEditable(false); TxtMPayment.setBounds(col+150,row+60,w,h);

TxtTPayment = new JTextField(); TxtTPayment.setEditable(false); TxtTPayment.setBounds(col+150,row+80,w,h);

//Add all components to layout

c.add(LblRate);

c.add(TxtRate);

c.add(LblYear);

c.add(TxtYear);

c.add(LblAmount);

c.add(TxtAmount);

c.add(LblMPayment);

c.add(TxtMPayment);

c.add(LblTPayment);

c.add(TxtTPayment);

c.add(BtnCalculate);

BtnCalculate.addActionListener(new Class3());

setSize(400,250);

setTitle("Tax Calculation");

setVisible(true);

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}

}

//***********************Class03***************************************

class Class3 implements ActionListener

{

//Set action on calculate button click

public void actionPerformed(ActionEvent ae)

{

//Get values & calculate based on given formula

float interest = Float.parseFloat(Class2.TxtRate.getText());

interest*=0.01;

interest/=12;

float years = Float.parseFloat(Class2.TxtYear.getText());

years*=12;

float amount = Float.parseFloat(Class2.TxtAmount.getText());

float monthlyPayment = (interest*amount)/(1-(float)Math.pow((1+interest),-years));

//Print the result

String formatedValue = String.format("%.2f", monthlyPayment);

Class2.TxtMPayment.setText(formatedValue);

formatedValue = String.format("%.2f", (years*monthlyPayment));

Class2.TxtTPayment.setText(formatedValue);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote