Create a Java Program/Class named ComputeInterest to calculate compound interest.
This can all be done entirely in the main() method.
Create a double variable named currentBalance.
Example:
Number of years to invest:5
Amount to Invest:1000
Year 1 balance = 1050.00 Year 2 balance = 1102.50 Year 3 balance = 1157.63 Year 4 balance = 1215.51 Year 5 balance = 1276.28 also Display the message "You have doubled your investment" and terminate the loop if/when you have more than doubled your initial investment. It is understood that the number of years to invest must be high enough to trigger this event.
code:
import java.util.*;
//util
package for scanner class
import java.text.DecimalFormat;
//DecimalFormat class for rounding the balance to two
decimals
public class CompoundInterest
{
public static void main(String args[])
//main
function
{
Scanner input=new
Scanner(System.in);
//scanner
class for input taking purpose
DecimalFormat decimal = new
DecimalFormat("##.00");
//decimal object for rounding to two decimal
values
double
CurrentBalance,NewBalance;
//currentbalance and newbalance variables declaration
final double
INTEREST_RATE=1.05;
//final double interest_rate variable
int yearCount;
System.out.println("Number of years
to invest");
//asking user to enter the number of years to invest
yearCount=input.nextInt();
System.out.println("Amount to
invest");
//enter
the amount to invest
CurrentBalance=input.nextDouble();
NewBalance=CurrentBalance;
//assigning current balance
to new balance
for (int
i=0;i<yearCount;i++)
//iterating loop for every year
{
NewBalance=NewBalance*INTEREST_RATE;
//calculating new balance
from given formula
System.out.println("Year " + (i+1) +" balance = " +
decimal.format(NewBalance));
//printing the new balance value of every year
if
(NewBalance>2*CurrentBalance)
// if the new balance exceeds double of original
investement
{
System.out.println("You have doubled your
investment"); //print the statement
and break the loop
break;
}
}
}
}
code screenshots and output:
Note : if you have any queries please post a comment thanks a lot......
Create a Java Program/Class named ComputeInterest to calculate compound interest. This can all be done entirely...
Create a Java Program to calculate baggage charges. Here are the rules: A. Two bags per person are free. B. The Excess Bag Charge is $75 per bag. The program needs to do the following: 1. In your main method(), Create integers to store the number of Passengers and also the total number of bags Prompt for the number of passengers on a ticket. Prompt for the total number of bags for all passengers on a ticket....
Write a Java program to do the following with your name. This can all be done in the main() method. 1. Create a String variable called myName and assign your personal name to it. Use proper capitalization for a legal name. I.e. String myName = "Billy Bob"; 2. Load myName with the upper case version of itself and display the result. 3. Load myName with the lower case version of itself and display the result. 4. Capitalize the first letter...
THE FOLLOWING PROGRAM IS NEEDED IN JAVA LANGUAGE Design a class torepresent account, include the following members: -Data Members a)Name of depositor-Stringb)Account Number –intc)Type of account –Boolean d)Balance amount -doublee)AnnualInterestrate -double Methods: -(a)To assign initial values (use constructor)(b)To deposit an amount.(c)TO withdraw amount with the restriction the minimum balance is 50 rs. Ifyouwithdraw amount reduced the balance below 50 then print the error message.(d)Display the name and balance of the account.(e)Get_Monthly_intrestRate() -Return the monthly interestrate whichis nothing but Annualintrestrate/12. Annualinterestrate...
Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....
Taking this program how can the requirements under it be added in java? import java.util.Scanner; public class RetirementSavings { private static final int MAX_SALARY = 300000; private static final double MAX_SAVING_RATE = 0.3; private static final double MAX_INTEREST_RATE = 0.2; private static final int MAX_YEAR_EMPLOYED = 40; public static void main(String[] args) { double savings_rate, interest_rate; int salary, years_employed; String name = ""; // name is initialized with an...
Can you help me to create this program, please? Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...
Write a program in Python that computes the interest accrued on an account. You can modify the “futval.py” program given in Chapter 2 to accomplish it. Your program should use a counted loop rather than a formula. It should prompt the user to enter the principal amount, the yearly interest rate as a decimal number, the number of compounding periods in a year, and the duration. It should display the principal value at the end of the duration. To compute...
Java Programming Create a program named MovieTest The program will create 10 Movie objects and place them in an array or ArrayList of type Movie. The program must do the following (all in main): Create an array or ArrayList of type Movie. Use the data in the text file that is in the download for the Movie file to create 10 Movie objects. Store the 10 Movie objects in the array or ArrayList. You MUST use the date in the...
Write a simple Java program with the following naming structure: Open Eclipse Create a workspace called hw1 Create a project called hw1 (make sure you select the “Use project folder as root for sources and class files”) Create a class called Hw1 in the hw1 package (make sure you check the box that auto creates the main method). Add a comment to the main that includes your name Write code that demonstrates the use of each of the following basic...
Write a java netbeans program. Project Two, Super Bowl A text file named “SuperBowlWinners.txt” contains the names of the teams that won the Super Bowl from 1967 through 2019. Write a program that repeatedly allows a user to enter a team name and then displays the number of times and the years in which that team won the Super Bowl. If the team entered by the user has never won the Super Bowl, report that to the user instead. For...