StudentLoans class
6 Code a method displayLoanAmounts(). This method display all the loan amounts and the interest on those amounts. Output format example:
Loan amounts and Interest
--------------------------
10000.0 500.0
-------------------------
50000.0 2500.0
-------------------------
20000.0 2000.0
-------------------------
import java.util.Scanner;
public class StudentLoans {
static void displayLoanAmounts() {
Scanner input=new Scanner(System.in);
System.out.println("Enter the loan amount: ");
double x=input.nextDouble();
double discount=x*0.2;
System.out.println("----------------");
System.out.print(x);
System.out.print(" ");
System.out.print(discount);}
public static void main(String[] args) {
displayLoanAmounts();
}
}
Comments
Leave a comment