Answer to Question #241411 in Java | JSP | JSF for Princess

Question #241411

The application must calculate the compound interest of the amount entered at the required investment type. Moderate investments receive 10% interest, while the aggressive receives 15% interest per year for the selected term. A sample output based on the selection above would be: (10) Q.1.4 Comment your program;  Marks will be allocated to the declaration of objects, logic, class definitions, method calls, etc.


1
Expert's answer
2021-09-25T03:03:17-0400


import javax.swing.JOptionPane;


public class Main {


	/**
	 * main menu
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		// Read name
		String customerName = JOptionPane.showInputDialog("Enter name: ");
		// Read original amount
		double originalAmount = Double.parseDouble(JOptionPane.showInputDialog("Enter original amount: "));
		int yearsInvested = Integer.parseInt(JOptionPane.showInputDialog("Enter number of years invested: "));
		//calculate the compound interest
		double finalAmount = originalAmount *(Math.pow((1.0 + (10.0 / 100.0)), yearsInvested));
		finalAmount = originalAmount *(Math.pow((1.0 + (15.0 / 100.0)), yearsInvested));
	
		String result = "INVESTMENT REPORT\n" + "CUSTOMER NAME: " + customerName + "\nORIGINAL AMOUNT R "
				+  String.format("%.2f", originalAmount) + "\nYEARS INVESTED " + yearsInvested + "\n" + "FINAL AMOUNT: R "
				+ String.format("%.2f", finalAmount);
		// display result
		JOptionPane.showMessageDialog(null, result);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS