import java.io.*;
public class DCS2{
public static void main (String [] args)
throws IOException{
BufferedReader myInput = new BufferedReader (new InputStreamReader(System.in));
int code, al, nmp, brc;
float tf = 0 , ir = 0;
String name = "" , description = "";
System.out.println ("Enter Your Barrower's Name");
name = myInput.readLine();
System.out.println("Enter Your Amount Loan");
al = Integer.parseInt(get.readLine());
System.out.println("Enter No. Of Months to Pay");
nmp = Integer.parseInt(get.readLine());
System.out.println("Enter Barrowers Rank code [ A - B]");
code = Integer.parseInt(myInput.readLine());
switch (code){
case A:
description = "SENIOR";
if (al >= 10001)
ir = .075;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 10000) && (al >= 6001))
ir = .06;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 6000) && (al >= 3001))
ir = .045;
i = al*ir*nmp;
ma = ad/nmp;
else if (al > 3000)
ir = .03;
i = al*ir*nmp;
ma = ad/nmp;
else
break;
case B:
description = "JUNIOR";
if (al >= 10001)
ir = .085;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 10000) && (al >= 6001))
ir = .07;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 6000) && (al >= 3001))
ir = .055;
i = al*ir*nmp;
ma = ad/nmp;
else if (al > 3000)
ir = .04;
i = al*ir*nmp;
ma = ad/nmp;
else
break;
default:
System.out.println("A or B only");
break;
}
System.out.println("Barrower's Name: " + name);
System.out.println("Rank Description : " + description);
System.out.println("Amount Loan: " + al);
System.out.println("Interest: " + i);
System.out.println("Amount Due: " + ad);
System.out.println("Monthly Amortization: " + ma);
}
}
--------------------Configuration: <Default>--------------------
C:\Users\asus\Documents\Comsys\DCS2.java:24: 'else' without 'if'
else if ((al < 10000) && (al >= 6001))
^
C:\Users\asus\Documents\Comsys\DCS2.java:28: 'else' without 'if'
else if ((al < 6000) && (al >= 3001))
^
C:\Users\asus\Documents\Comsys\DCS2.java:32: 'else' without 'if'
else if (al > 3000)
^
C:\Users\asus\Documents\Comsys\DCS2.java:36: 'else' without 'if'
else
^
C:\Users\asus\Documents\Comsys\DCS2.java:44: 'else' without 'if'
else if ((al < 10000) && (al >= 6001))
^
C:\Users\asus\Documents\Comsys\DCS2.java:48: 'else' without 'if'
else if ((al < 6000) && (al >= 3001))
^
C:\Users\asus\Documents\Comsys\DCS2.java:52: 'else' without 'if'
else if (al > 3000)
^
C:\Users\asus\Documents\Comsys\DCS2.java:56: 'else' without 'if'
else
^
8 errors
Process completed.
Using JOptionPane code.
import javax.swing.io.*;
public class DCS2b{
public static void main (String [] args){
int code, al, nmp, brc;
float tf = 0 , ir = 0;
String name = "" , description = "";
name = JOptionPane.showInputDialog("Enter Your Barrower's Name");
al = JOptionPane.showInputDialog("Enter Your Amount Loan");
nmp = JOptionPane.showInputDialog("Enter No. Of Months to Pay");
code = Integer.parseInt(JOptionPane.showInputDialog("Enter Barrowers Rank code [ A - B]"));
switch (code){
case A:
description = "SENIOR";
if(al >= 10001)
ir = .075;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 10000) && (al >= 6001))
ir = .06;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 6000) && (al >= 3001))
ir = .045;
i = al*ir*nmp;
ma = ad/nmp;
else if (al > 3000)
ir = .03;
i = al*ir*nmp;
ma = ad/nmp;
else
break;
case B:
description = "JUNIOR";
if(al >= 10001)
ir = .085;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 10000) && (al >= 6001))
ir = .07;
i = al*ir*nmp;
ma = ad/nmp;
else if ((al < 6000) && (al >= 3001))
ir = .055;
i = al*ir*nmp;
ma = ad/nmp;
else if (al > 3000)
ir = .04;
i = al*ir*nmp;
ma = ad/nmp;
else
break;
default:
System.out.println("A or B only");
break;
}
JOptionPane.showMessageDialog(null, "Hello " + name + "!", "name", "Rank Description : " + description , "description" , "Amount Loan: " + al , "al", "Interest: " + i , "i", "Amount Due: " + ad , "ad", "Amount Due: " + ad , "ad" , "Monthly Amortization: " + ma, "ad",JOptionPane.PLAIN_MESSAGE);
}
}
--------------------Configuration: <Default>--------------------
C:\Users\asus\Documents\Comsys\DCS2b.java:18: 'else' without 'if'
else if ((al < 10000) && (al >= 6001))
^
C:\Users\asus\Documents\Comsys\DCS2b.java:22: 'else' without 'if'
else if ((al < 6000) && (al >= 3001))
^
C:\Users\asus\Documents\Comsys\DCS2b.java:26: 'else' without 'if'
else if (al > 3000)
^
C:\Users\asus\Documents\Comsys\DCS2b.java:30: 'else' without 'if'
else
^
C:\Users\asus\Documents\Comsys\DCS2b.java:38: 'else' without 'if'
else if ((al < 10000) && (al >= 6001))
^
C:\Users\asus\Documents\Comsys\DCS2b.java:42: 'else' without 'if'
else if ((al < 6000) && (al >= 3001))
^
C:\Users\asus\Documents\Comsys\DCS2b.java:46: 'else' without 'if'
else if (al > 3000)
^
C:\Users\asus\Documents\Comsys\DCS2b.java:50: 'else' without 'if'
else
^
8 errors
Process completed.