Question

In: Computer Science

Bank Accounts in Java! Design and implement a Java program that does the following: 1) reads...

Bank Accounts in Java!

Design and implement a Java program that does the following:

1) reads in the principle

2) reads in additional money deposited each year (treat this as a constant)

3) reads in years to grow, and

4) reads in interest rate

And then finally prints out how much money they would have each year.

See below for formatting.

Enter the principle: XX

Enter the annual addition: XX

Enter the number of years to grow: XX

Enter the interest rate as a percentage: XX

Year 0: $XX

Year 1: $XX

Year 2: $XX

Year 3: $XX

Year 4: $XX

Year 5: $XX

Solutions

Expert Solution

Answer:

import java.io.*;
import java.util.Scanner;
class bank
{
public static void main(String[] args)
{
   int principle,additinal_money,years,rate;
   Scanner input = new Scanner(System.in);
  
   System.out.println("Enter the principle: ");
   principle = input.nextInt();
   System.out.println("Enter the annual addition: ");
   additinal_money = input.nextInt();
   System.out.println("Enter the number of years to grow: ");
   years = input.nextInt();
   int [] new_amount = new int[years];
   System.out.println("Enter the interest rate: ");
   rate = input.nextInt();
   for(int i=0;i<years;i++)
   {
      
       new_amount[i] = principle*rate/100;
       principle+= new_amount[i];
       principle = principle+additinal_money;
       new_amount[i] = principle;
   }
   for( int i=0;i<years;i++)
   {
       System.out.println("year"+i+": $"+new_amount[i]);
   }
}
}
      


Related Solutions

programing language JAVA: Design and implement an application that reads a sentence from the user, then...
programing language JAVA: Design and implement an application that reads a sentence from the user, then counts all the vowels(a, e, i, o, u) in the entire sentence, and prints the number of vowels in the sentence. vowels may be upercase
Design and implement a program that reads a series of 10 integers from the user and...
Design and implement a program that reads a series of 10 integers from the user and prints their average. Read each input value as a string, and then attempt to convert it to an integer using the Integer.parseInt method. If this process throws a NumberFormatException (meaning that the input is not a valid number), print an appropriate error message and prompt for the number again. Continue reading values until 10 valid integers have been entered.
Design and implement a Java program that creates a GUI that will allow a customer to...
Design and implement a Java program that creates a GUI that will allow a customer to order pizza and other items from a Pizza Paarlor. The customer should be able to order a variety of items which are listed below. The GUI should allow the customer (viaJavaFX UI Controls - text areas, buttons, checkbox, radio button, etc.) to input the following information: Name of the customer First Name Last Name Phone number of the customer Type of food being order...
USING C# Design and implement a program (name it SumValue) that reads three integers (say X,...
USING C# Design and implement a program (name it SumValue) that reads three integers (say X, Y, and Z) and prints out their values on separate lines with proper labels, followed by their average with proper label. Comment your code properly.Format the outputs following the sample runs below. Sample run 1: X = 7 Y = 8 Z = 10 Average = 8.333333333333334
Implement in Python a script that does the following: 1) reads input from a supposed file...
Implement in Python a script that does the following: 1) reads input from a supposed file called firstnames_2.txt. 2) processes the input and writes and saves the output to a file. NOTE: Please make sure that the names are written in the outfile with one name on each line no comma ( , ) after the name in the output
*Java program* Use while loop 1.) Write a program that reads an integer, and then prints...
*Java program* Use while loop 1.) Write a program that reads an integer, and then prints the sum of the even and odd integers. 2.) Write program to calculate the sum of the following series where in is input by user. (1/1 + 1/2 + 1/3 +..... 1/n)
Language: Java Design and implement a program that implements an Interpolation Search method. Interpolation search is...
Language: Java Design and implement a program that implements an Interpolation Search method. Interpolation search is similar to binary search, except it tries to begin the search nearer to the location of the item. Instead of the using the middle value of the sorted array, interpolation search estimates the location of the target with respect to the first & last values in the array. The implementation is the same as binary search except that you should calculate the mid value...
Write a Java program that reads a list of integers into an array. The program should...
Write a Java program that reads a list of integers into an array. The program should read this array from the file “input.txt”. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is a two-column list. The first column is the list of the distinct array elements; the second column is the number of occurrences of each element. The list should be sorted on entries in...
Write a program that performs the following two tasks in java Reads an arithmetic expression in...
Write a program that performs the following two tasks in java Reads an arithmetic expression in an infix form, stores it in a queue (infix queue) and converts it to a postfix form (saved in a postfix queue). Evaluates the postfix expression. Use linked lists to implement the Queue and Stack ADTs. DO NOT USE BUILT IN JAVA CLASSES
Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT