I am writing my first Java program. Just for practice and a learning experience for a complete beginner. The program is a retirement calculator and I am having an issue with the code not flowing directly into the next code that I wrote.
System.out.println("What investment style best suits your needs? i.e.(Very Aggressive, Aggressive, Moderate, Conservative)");
String investmentstyle = scanner.toString();
if (investmentstyle == "Very Aggressive") {
System.out.println("With this type of fund, almost 100% of your funds would go towards stocks. you could expect a 12% rate of return on your investment.");
}
else if (investmentstyle == "Aggressive") {
System.out.println("With this type of fund, 75% of your funds would go towards stocks and 25% would go towards bonds. You could expect a 9% rate of return on your investment.");
}
else if (investmentstyle == "Moderate") {
System.out.println("With this type of fund, 50% of your funds would go towards stocks and 50% would go towards bonds. You could expect a 6% rate of return on your investment.");
}
else if (investmentstyle == "Conservative") {
System.out.println("With this type of fund, 25% of your funds would go towards stocks and 75% would go towards bonds. You could expect a 3% rate of return on your investment.");
}
System.out.println("Please enter the expected return rate that is in accordance with the investment style you have chosen.\n Make sure you don't enter the percentage sign (%).");
double interestrate = scanner.nextDouble();
As you can see here, I am asking the user what type of fund he/she would be interested in. I want that input to be processed by the if/else to display the statement that correlates to the fund they chose. As of now, when I run the program it completely bypasses the if/else and moves on to then next question I ask. How would I go about fixing this?
As always, any and all help is appreciated. Thank you in advance!