Advertisement
rangga_hrdme

KINDS OF FUNCTION 3

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