Tuesday, May 22, 2018

java - Now am getting incompatible error when using the if else statements




trying to run the program below but am getting an error when using the switch method



import java.util.Scanner;



/**
*
* @author kern
public class loans {




public static void main(String[] args) {


Scanner input = new Scanner(System.in);



    //variabled decleared
double rate, payment,principal,interest,n;
int length;
String period;


//input
System.out.print("Enter the amount of money borrowed: $");
principal = input.nextDouble();
System.out.print("Enter the annual interest rate: ");
interest = input.nextDouble();
System.out.print("Enter the payment period :");
period = input.next();
System.out.print("Enter Loan Length:");
length = input.nextInt();
//process


rate=interest/100;
payment= principal*(rate*Math.pow((1+rate),n)/ Math.pow ((1+rate),n));

if (period==annually) {
n=1*length;
System.out.prtintf(Your monthly sum is %f:,payment);{

if (period==semiannuall) {
n=2*length;

System.out.prtintf(Your monthly sum is %f:,payment);{

if (period== quarterly) {
n=4*length;
System.out.prtintf(Your quarterly sum is %f:,payment);{

if (period==monthly) {
n=12*length;
System.out.prtintf(Your monthly sum is %f:,payment);{





}


}


Answer



String as case value are supported from java 7




See





You need to use it like



if("annually".equals(period)){
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...