Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. // Tianhao Wang
  2. // February 21, 2017
  3. // Assignment 5: Userinputs
  4. // ICS3U Ms. Strelkovska
  5.  
  6. import java.util.Scanner;
  7. public class userinputsss {
  8.     public static void main(String[] arg){
  9.         int money, quarters, dimes, nickels, cents;
  10.         Scanner in = new Scanner (System.in);
  11.         System.out.print("Enter amount of money in cents (less than a dollar): ");
  12.         money = in.nextInt();
  13.         quarters = money/25;
  14.         dimes= money%25/10;
  15.         nickels = money%25%10/5;
  16.         cents = money%25%10%5;
  17.         System.out.format("%-10s   %-10s   %-10s   %-10s   %-10s \n", "Money", "Quarters", "Dimes", "Nickels", "Cents");
  18.         System.out.format("%-10s   %-10s   %-10s   %-10s   %-10s", money, quarters, dimes, nickels, cents);
  19.         System.out.println("\n");
  20.         double p = 0,a = 0;
  21.         int i = 0, n = 0;
  22.         String name = "";
  23.         System.out.print("Enter a name: ");
  24.         in.nextLine();
  25.         name = in.nextLine();
  26.         System.out.print("Enter amount of money you would like to invest: ");
  27.         p= in.nextDouble();
  28.         System.out.print("Enter yearly interest rate: ");
  29.         i = in.nextInt();
  30.        
  31.         System.out.print("Enter the amount of years you would like to invest: ");
  32.         n = in.nextInt();
  33.         a = p*Math.pow((1+(((double)i/(double)100)/12.0)),(n*12.0));
  34.        
  35.         System.out.println(name+" your amount of investment after "+n+" years is "+Math.round(a*100)/100.0+" dollars");
  36.        
  37.        
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement