import java.util.Scanner;
public class Methods {
/*
* Compound interest Program Quarterly
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner (System.in);
System.out.println("What is the Rate");
int rate = keyboard.nextInt()/100;
System.out.println("What is the Amount");
int amount = keyboard.nextInt();
System.out.println("How many years?");
int years = keyboard.nextInt();
keyboard.nextLine();
System.out.println("How is it compounded? Press Q = Quarterly, A = Anually, S = SemiAnnualy, M = Monthly");
String answer = keyboard.nextLine();
int easy = amount*(1+(rate/years));
int pow = 4 * years;
if (answer == "/Q"){
System.out.println("Your answer compounded Quarterly is: " + Math.pow(easy,pow));
This is the code, but the if statement with String == "Q" doesn't work because when I press Q nothing happens? what's the issue?
Aucun commentaire:
Enregistrer un commentaire