Advertisement
rangga_hrdme

KINDS OF FUNCTION 2

Apr 26th, 2021
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 KB | None | 0 0
  1. // FUNCTION(PARAMETER)
  2. import java.util.Scanner;
  3. import java.lang.*;
  4.  
  5. public class func_depreciation {
  6.     public static double Asset, Estimation;
  7.     public static int Period, Start, End;
  8.  
  9.     public static void main(String[] args) {
  10.         Scanner text = new Scanner(System.in);
  11.         System.out.println("Depreciation : Straight Line Method");
  12.         System.out.print("Cost of Bought: ");
  13.         Asset = text.nextDouble();
  14.         System.out.println("Period of Depreciation(Year): ");
  15.         System.out.print("Period (Integer): ");
  16.         Period = text.nextInt();
  17.         System.out.print("Begin of Year (Integer): ");
  18.         Start = text.nextInt();
  19.         System.out.print("End of Year (Integer): ");
  20.         End = text.nextInt();
  21.         System.out.print("Residual value(Float): ");
  22.         Estimation = text.nextDouble();
  23.         StraightLine(Asset, Period, Start, End, Estimation);
  24.     }
  25.  
  26.     private static void StraightLine(double Asset, int Period, int Start, int End, double Estimation) {
  27.         if (Asset > 0 && Period > 0 && Start > 0 && End > 0) {
  28.             double depreciation = ((Asset - Estimation) / Period);
  29.             System.out.println(String.format(" Depreciation/ Year : %,.2f", depreciation));
  30.             System.out.println("| Year |     Amount   -   Accummulation   =   Resid |");
  31.         } else {
  32.             System.out.println(" Minimal Integer: 1");
  33.         }
  34.  
  35.         for (int x = Start; x <= End; x++) {
  36.             double fraction = ((double) x) / ((double) Period);
  37.             double accummulation = fraction * (Asset - Estimation);
  38.             double resid = Asset - accummulation;
  39.             System.out.println(String.format("%d   %,.2f - %,.2f = %,.2f", x, Asset, accummulation, resid));
  40.         }
  41.     }
  42. }
  43. // 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