Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.70 KB | None | 0 0
  1. /**
  2.  * Assignment 58h
  3.  *
  4.  * Cody O
  5.  * 9/14/19
  6.  */
  7.  
  8. import java.util.*;
  9. import java.lang.*;
  10. import java.text.*;
  11.  
  12. public class Program_58h_CodyO
  13. {
  14.    public static void main (String[]args)
  15.    {
  16.     NumberFormat money = NumberFormat.getCurrencyInstance();
  17.     Scanner input  = new Scanner(System.in);
  18.     DecimalFormat fmt = new DecimalFormat("#");
  19.     //input
  20.     System.out.println("Amount Saved ");
  21.     double savedA = input.nextInt();
  22.     System.out.println("Interest rate?");
  23.     double rateA = input.nextDouble();
  24.     System.out.println("Number of times compounded per year?");
  25.     double amountA = input.nextInt();
  26.     System.out.println("Numbers of days at interest?");
  27.     double daysA = input.nextInt();
  28.    
  29.     //math
  30.     double topA = .01 * rateA;
  31.     double outsideA = (amountA * daysA) / 365.000;
  32.     double insideA = 1 + (topA / amountA);
  33.     double lastA = savedA * (Math.pow(insideA, outsideA));
  34.     //output
  35.     System.out.println(" ");
  36.     System.out.println("The interest earned is " + money.format(lastA - savedA));
  37.     System.out.println("The total amount in savings is now " + money.format(lastA));
  38.    
  39.     //input
  40.     System.out.println("Amount Saved ");
  41.     double savedB = input.nextInt();
  42.     System.out.println("Interest rate?");
  43.     double rateB = input.nextDouble();
  44.     System.out.println("Number of times compounded per year?");
  45.     double amountB = input.nextInt();
  46.     System.out.println("Numbers of days at interest?");
  47.     double daysB = input.nextInt();
  48.    
  49.     //math
  50.     double topB = .01 * rateB;
  51.     double outsideB = (amountB * daysB) / 365.000;
  52.     double insideB = 1 + (topB / amountB);
  53.     double lastB = savedB * (Math.pow(insideB, outsideB));
  54.     //output
  55.     System.out.println(" ");
  56.     System.out.println("The interest earned is " + money.format(lastB - savedB));
  57.     System.out.println("The total amount in savings is now " + money.format(lastB));
  58.    
  59.     //input
  60.     System.out.println("Amount Saved ");
  61.     double savedC = input.nextInt();
  62.     System.out.println("Interest rate?");
  63.     double rateC = input.nextDouble();
  64.     System.out.println("Number of times compounded per year?");
  65.     double amountC = input.nextInt();
  66.     System.out.println("Numbers of days at interest?");
  67.     double daysC = input.nextInt();
  68.    
  69.     //math
  70.     double topC = .01 * rateC;
  71.     double outsideC = (amountC * daysC) / 365.000;
  72.     double insideC = 1 + (topC / amountC);
  73.     double lastC = savedC * (Math.pow(insideC, outsideC));
  74.     //output
  75.     System.out.println(" ");
  76.     System.out.println("The interest earned is " + money.format(lastC - savedC));
  77.     System.out.println("The total amount in savings is now " + money.format(lastC));
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement