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

HW 2 - Using If statement to respond to the following conditions: 1. If your cre

ID: 3588823 • Letter: H

Question

 HW 2 - Using If statement to respond to the following conditions:  1. If your credit score is greater than 740, display a message: "Your loan has been approved"  2. If not, ask another if statement of the credit score If your score is between 700 and 739, display a message "conditional approval"  If all failed, then show "Denied" JAVA PROGRAM  Requirements:  1. Need to import javax.swing.JOptionPane class to get input from the users.  2. You need to get all conditions, including what if users put in  their credit score below zero of higher than 850 (maximum credit score) 

Explanation / Answer

import javax.swing.JOptionPane;

public class LoanExample

{

public static void main(String args[])

{

int amount = Integer.parseInt(JOptionPane.showInputDialog(null,"Enter loan amount" ));

if(amount >= 0 && amount <= 850)

{

if(amount < 700)

JOptionPane.showMessageDialog(null,"Denied");

else if(amount >= 700 && amount <= 739)

JOptionPane.showMessageDialog(null,"Condition approval");

else if(amount >= 740)

JOptionPane.showMessageDialog(null,"Your loan has been approved");

}

else

JOptionPane.showMessageDialog(null,"Invalid loan amount");   

}

}