Question: (JAVA) I need help for the assignment !! this is my code below, but I want this code output all 4 pictures below ( I
(JAVA)
I need help for the assignment !!
this is my code below, but I want this code output all 4 pictures below ( I got first 3 )
package hello;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class labExercise1 {
public static void main(String[] args) { int sum= 0; double interestRate = 5.0; double monthlyPayment=0; double totalPayment=0; String input = JOptionPane.showInputDialog(null,"Enter the loan amount: ($)","Lab Exercise 1", 2); double loanAmount = Double.parseDouble(input); String input1 = JOptionPane.showInputDialog(null,"Enter the loan period(years):","Lab Exercise 1",2); double numberOfYears = Double.parseDouble(input1); JOptionPane.showConfirmDialog(null,"The loan amount is $" + loanAmount + ", and the loan duration is " + numberOfYears + "year(s). Continue?","Lab Exercise 1",2);
String s1 = null; System.out.print("Interest Rate(%) Monthly Payment($) Total Payment($) ");
while (interestRate
interestRate = interestRate + 1.0 / 8; }
s1 = String.format("%16.3f%19.2f%19.2f ",interestRate, monthlyPayment, totalPayment); System.out.println(s1); JOptionPane.showMessageDialog(null,s1,"Lab Exercise 1",3);
}
} ==============
direction
=============
JOptionPanedialogs to get the users inputs, confirm the information, and print out the loan amount.
You will use the following dialog boxes:
- JOptionPane.showInputDialog ask the loan amount($), and loan duration (years)
- JOptionPane.showConfirmDialog display the loan amount and loan duration to get the users confirmation. (If the users confirmation is no, the dialog will ask for users input again.)
- JOptionPane.showMessageDialog display the loan payment with annual interest rate from 5%~8% every 1/8%.
- Make sure to change the title of each dialog box to Lab Exercise 1 instead of the default title.
- After get the users inputs, make sure to convert the Strings into numbers.
-
double amount = Double.parseDouble(string1);
-
int year = Integer.parseDouble(string2);
-
- Use String.format() to format the output before display in the message dialog.


Lab Exercise1 Lab Exercise 1 Enter the loan amount: (S) Please enter the loan period (years) ) 1000 Cancel OK Cancel OK Lab Exercise 1 The loan amount is 1000.00, and the loan duration is 2 year(s). Continue! No Yes Lab Exercise 1 Monthly Payment($) Total Payment($) Interest Rate(%) 5.000 5.125 5.250 5.375 5.500 5.625 5.750 5.875 6.000 6.125 6.250 6.375 6.500 6.625 6.750 6.875 7.000 7.125 7.250 7.375 7.500 7.625 7.750 7.875 8.000 43.87 43.93 43.98 44.04 44.10 44.15 44.21 44.26 44.32 44.38 44.43 44.49 44.55 44.60 44.66 44.72 44.77 44.83 44.89 44.94 45.00 45.06 45.11 45.17 45.23 1052.91 1054.26 1055.60 1056.9!5 1058.30 1059.64 1060.99 1062.34 1063.69 1065.05 1066.40 1067.75 1069.11 1070.47 1071.82 1073.18 1074.54 1075.90 1077.26 1078.63 1079.99 1081.3!5 1082.72 1084.09 1085.45
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
