Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // METHOD (FUNCTION HAS RETURN)
- import java.util.Scanner;
- public class func_dep_return {
- public static double Asset, Estimation;
- public static int Start, End;
- public static void main(String[] args) {
- Scanner text = new Scanner(System.in);
- System.out.println("Depreciation : Straight Line Method");
- System.out.print("Cost of Bought: ");
- Asset = text.nextDouble();
- System.out.println("Period of Depreciation(Year): ");
- System.out.print("Begin of Year (Integer): ");
- Start = text.nextInt();
- System.out.print("End of Year (Integer): ");
- End = text.nextInt();
- System.out.print("Residual value(Float): ");
- Estimation = text.nextDouble();
- StraightLine(Asset, Start, End, Estimation);
- }
- private static double StraightLine(double Asset, int Start, int End, double Estimation) {
- if (Asset > 0 && Start > 0 && End > 0) {
- double depreciation = ((Asset - Estimation) / End);
- System.out.println(String.format(" Depreciation/ Year : %,.2f", depreciation));
- System.out.println("| Year | Amount - Accummulation = Resid |");
- } else {
- System.out.println(" Minimal Integer: 1");
- }
- double fraction = ((double) Start) / ((double) End);
- double accummulation = fraction * (Asset - Estimation);
- double resid = Asset - accummulation;
- System.out.println(String.format("%d %,.2f - %,.2f = %,.2f", Start, Asset, accummulation, resid));
- return resid;
- }
- }
- // Pray 4 Uyghur: https://bylinetimes.com/2020/08/24/death-is-everywhere-millions-more-uyghurs-missing/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement