任何易受磨损的物品或物品的价值会随着时间的流逝而降低。这种减少称为折旧。给定三个变量V1 , R和T ,其中V1是初始值, R是折旧率, T是时间(以年为单位)。任务是在T年后找到项目的价值。
例子:
Input: V1 = 200, R = 10, T = 2
Output: 162
Input: V1 = 560, R = 5, T = 3
Output: 480.13
方法:与复利一样,在约定的时间间隔结束时定期将利息添加到本金,以生成新的本金。同样,折旧值是指从商定的时间间隔结束时的金额减去的金额,以生成新的值。
因此,如果V1是某个时间的值,而每年R%是每年的折旧率(该率不能超过100%),则T年末的V2值是:
下面是上述方法的实现:
C++
// CPP program to find depreciation of the value
// initial value, rate and time are given
#include
using namespace std;
// Function to return the depreciation of value
float Depreciation(float v, float r, float t)
{
float D = v * pow((1 - r / 100), t);
return D;
}
// Driver Code
int main()
{
float V1 = 200, R = 10, T = 2;
cout << Depreciation(V1, R, T);
return 0;
}
Java
// Java program to find depreciation of the value
// initial value, rate and time are given
import java.io.*;
class GFG
{
// Function to return the depreciation of value
static float Depreciation(float v,
float r, float t)
{
float D = (float)(v * Math.pow((1 - r / 100), t));
return D;
}
// Driver code
public static void main(String[] args)
{
float V1 = 200, R = 10, T = 2;
System.out.print(Depreciation(V1, R, T));
}
}
// This code is contributed by anuj_67..
Python3
# Python 3 program to find depreciation of the value
# initial value, rate and time are given
from math import pow
# Function to return the depreciation of value
def Depreciation(v, r, t):
D = v * pow((1 - r / 100), t)
return D
# Driver Code
if __name__ == '__main__':
V1 = 200
R = 10
T = 2
print(int(Depreciation(V1, R, T)))
# This code is contributed by
# Surendra_Gangwar
C#
// C# program to find depreciation of the value
// initial value, rate and time are given
using System;
class GFG
{
// Function to return the depreciation of value
static float Depreciation(float v, float r, float t)
{
float D = (float) (v * Math.Pow((1 - r / 100), t));
return D;
}
// Driver code
public static void Main()
{
float V1 = 200, R = 10, T = 2;
Console.WriteLine(Depreciation(V1, R, T));
}
}
// This code is contributed by nidhiva
输出:
162