Edit question
1. Write an application with three labeled text fields, one each for the initial amount of a savings account, the annual interest rate, and the number of years. Add a button “Calculate” and a read-only text area to display the balance of the savings account after the end of each year.
You can create a text area with:
private JTextArea balanceArea;
and initialize it with:
balanceArea = new JTextArea(20, 20); <-- 20, 20 is the height, width
You can make it read-only with:
balanceArea.setEditable(false);
When the Calculate button is clicked, use a loop to calculate the updated balance for each year, and use the .append() method of the JTextArea to print the balance for each year; e.g.,
balanceArea.append(balance + "\n");
Create a file named gui.java and paste the below code in it
CODE:
import javax.swing.*;
import java.awt.event.*;
public class gui extends JFrame {
public static void main(String[] args)
{
JFrame f= new JFrame("Interest
calculator"); //JFrame object
final JTextField t1,t2,t3; //Textfields
t1=new JTextField();
JLabel lab1 = new JLabel("Initial savings amount:");
//label for textfield1
lab1.setBounds(20, 100, 200, 30);
t1.setBounds(200,100, 200,30);
t2=new JTextField();
JLabel lab2 = new JLabel("Annual Interest Rate:");
//label for textfield2
t2.setBounds(200,150, 200,30);
lab2.setBounds(20, 150, 200, 30);
t3=new JTextField();
JLabel lab3 = new JLabel("Number of years:"); //label
for textfield3
t3.setBounds(200,200,200,30);
lab3.setBounds(20, 200, 200, 30);
JButton jb=new JButton("Calculate Interest");
//JButton b=object
jb.setBounds(150,250,200,30);
final JTextArea jt=new JTextArea(10,10); //JTextarea
object
jt.setBounds(150,300,300,200);
jt.setEditable(false);
//adding all the components to JFrame object
f.add(t1); f.add(t2);
f.add(t3);f.add(jb);f.add(lab1);;f.add(lab2);f.add(lab3);f.add(jt);
f.setSize(600,600); //setting layout size
f.setLayout(null);
f.setVisible(true);
//onclick listener for JButton
jb.addActionListener(new ActionListener(){
public void
actionPerformed(ActionEvent e){
try{
jt.setText("");
//getting
values from text fields
double
savingsAmount=Double.parseDouble(t1.getText().trim());
double
interestRate=Double.parseDouble(t2.getText().trim());
int
noy=Integer.parseInt(t3.getText().trim());
double
balance=savingsAmount;
//calculating saving amount for each year
for(int
i=1;i<=noy;i++)
{
balance=balance+((interestRate*balance)/100);
jt.append("Balance in
year"+i+"-"+balance+"\n");
}
}
catch(Exception excep)
{
jt.setText("Enter Valid Values!");
t1.setText("");
t2.setText("");
t3.setText("");
}
}
});
}
}
OUTPUT:


Please rate my answer if you liked it.
Edit question 1. Write an application with three labeled text fields, one each for the initial...
USING JAVA and NOTTT using BufferedReader or BufferedWriter Write an application that implements a simple text editor. Use a text field and a button to get the file. Read the entire file as characters and display it in a TextArea. The user will then be able to make changes in the text area. Use a Save button to get the contents of the text area and write that over the text in the original file. Hint: Read each line from...
in java plz and not using bufferedreader or bufferedwriter!! Write an application that implements a simple text editor. Use a text field and a button to get the file. Read the entire file as characters and display it in a TextArea. The user will then be able to make changes in the text area. Use a Save button to get the contents of the text area and write that over the text in the original file. Hint: Read each line...
JAVASCRIPT
Write a GUI application that has three labels, two text fields, and two buttons (with the titles Name and Age). When the program starts the user will enter his/her first name in the first text field and his age in the second text field. When the user clicks the Name button, the first name entered by the user will be displayed as a separate label with the words "CSC210 student at the back of it. When the user clicks...
i
need this done in java
plz, add comments for every single method. also, make as
simple as possible.
3. Write a GUI for computing the statistics of numbers input from the user. The GUI should have a text field and a button for adding floating point numbers. Each time a number is entered have a label show the current max, min and average. Have your GUI accept numbers whether the button is pressed or the enter key is pressed...
This assignment is about creating the Rolodex application that contains the contact information. Each contact information includes: First name Last name Middle name (optional) Phone number The Rolodex application will use SharedPreferences for data persistent operations: Retrieve Rolodex records Add a new Rolodex record Update the existing Rolodex record Delete the selected Rolodex record The Rolodex application uses Fragment and DialogFragment. In addition, the Rolodex records are displayed in the ListView view. The ListView view is set to be single-selection...
***Please use java code for the question below*** Write a program that calculates the future value of a given investment at a given interest rate for a specified number of years. The formula for this calculation is: value = investmentAmount * (1 + monthly interest rate)years*12 Use text fields for the user to enter the numbers (Investment Amount, Number of Years, and Annual Interest). To get/load data from the textbox, (in this case doubles) use the following structure: (bold are...
Need help debugging Create a GUI application that accepts student registration data. Specifications: The text box that displays the temporary password should be read-only. The temporary password consists of the user’s first name, an asterisk (*), and the user’s birth year. If the user enters data in the first three fields, display a temporary password in the appropriate text field and a welcome message in the label below the text fields. If the user does not enter data, clear the...
Question #1 Write a javascript for an ATM withdrawal application. The ATM machine will only accept a transaction if the withdrawal amount X is a multiple of 20, and account has enough balance to perform withdrawal transaction (including bank charges) For each successful withdrawal the bank charges 0.50$. The account will have an initial balance of 500$. A) You have to declare an input type and a button in your HTML form with input type having a placeholder Enter withdrwal...
Write Linux command for each question. Please use one single commend to do following process. Q1: Display all lines of list1.txt and list2.txt containing the letter ‘p', and sort the result. Q2: Append “file1.txt” and “file2.txt”, and redirect to “file3.txt”. Q3: Sort “file3.txt”, and redirect the result to file “file4.txt” Q4: Use shorthand way to change the permission of “file3.txt” to “user - write read execute, group - read execute, other - execute”. Q5: Extract first column from “file3.txt”, and...
This homework problem has me pulling my hair out. We are working
with text files in Java using NetBeans GUI application. We're
suppose to make a movie list and be able to pull up movies already
in the text file (which I can do) and also be able to add and
delete movies to and from the file (which is what I'm having
trouble with). I've attached the specifications and the movie list
if you need it. Any help would...