Answer to Question #294796 in Java | JSP | JSF for sampath

Question #294796
Final Value with Appreciation

Given principal amount 

principal as an input, time period in years time and appreciation percentage apprPercentage as optional inputs, write a JS function to return the final value finalValue with the given appreciation percentage and time period. The default values for time and apprPercentage are 2 and 5 respectively.

Quick Tip

The formula to calculate the final value with appreciation is,


finalValue = principal * (1 + time * appreciation / 100)

Input
The first line of input contains a number principal
The second line (optional) of input contains a number time
The third line (optional) of input contains a number apprPercentage
Output
The output should be a single line containing the finalValue
Sample Input 1
1000
2
3
Sample Output 1
1060

Sample Input 2
3000
Sample Output 2
3300.0000000000005


but

sample input 2

2000

helf me how to solve it



1
Expert's answer
2022-02-07T12:50:36-0500
import java.util.*;


class App {
	static double calculateFinalValue(double principal, double time, double appreciation) {
		return principal * (1 + time * appreciation / 100);
	}


	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		System.out.print("Enter a number principal: ");
		double principal = in.nextDouble();
		System.out.print("Enter a number time: ");
		double time = in.nextDouble();
		System.out.print("Enter a number apprPercentage: ");
		double appreciation = in.nextDouble();
		System.out.println(calculateFinalValue(principal, time, appreciation));
		in.close();
	}
}

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