In Java please.Enter the code where it says " /* Your code goes here */ ".
Suppose we add a fixed amount of money into our bank account at the beginning of every year. Modify the
import java.util.Scanner;
/**
This program computes the time required to double an investment
with an annual contribution.
*/
public class DoubleInvestment
{
public static void main(String[] args)
{
final double RATE = 5;
final double INITIAL_BALANCE = 10000;
final double TARGET = 2 * INITIAL_BALANCE;
Scanner in = new Scanner(System.in);
System.out.print("Annual contribution: ");
double contribution = in.nextDouble();
double balance = INITIAL_BALANCE;
int year = 0;
// TODO: Add annual contribution, but not in year 0
/* Your code goes here */
System.out.println("Year: " + year);
System.out.printf("Balance: %.2f%n", balance);
}
}
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
- Don't give me AI generated answer or plagiarised answer. If I see these things I'll give you multiple downvotes and will report immediately.arrow_forwardJAVA Practice Question for Midterm Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the number of vowels in the string, and another method that returns the number of consonants in the string. Demonstrate the class in a program by invoking the methods that return the number of vowels and consonants. Print the counts returned. Imagine you are developing a software package for an online shopping site that requires users to enter their own passwords. Your software requires that users’ passwords meet the following criteria: The password should be at least six characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. a program that asks the user to enter a password, then displays a message indicating whether it is valid or not.arrow_forwardComplete the task in java and please dont use AI write it on your own.write it in simple code pleasearrow_forward
- 29 JAVA JAVA onlyarrow_forwardCensorship. Create a program that reads text, and produces a new output text in which all four-letter words are replaced with "****". For example, for input “The class was easy”, the program outputs “The was “.arrow_forwardJAVA please help me with this, I am stuck; I'd really appreciate it.arrow_forward
- For the code in java below it shows a deck of 52 cards and asks the name of the two players and makes both players draw five cards from the deck. What I want to be added into the code is that both Players are people that can select what card they pick and Player A starts. Player A picks a card in his/her hand. Player B gets to choose the two cards which add to the value of Player A’s card, if player B lies and the two cards they choose do not add up to A's card, player B loses a point, if player B does not have two cards whose value adds to the value of Player A’s card, then no one gets a point. Player’s A card (if selected) and the two cards from Player B are discarded both players draw back to 5 cards from the deck. Main class code: import java.util.ArrayList; import java.util.Scanner; import java.util.List; import java.util.Random; class Main { publicstaticvoid main(String[] args) { // card game, two players, take turns. String[] suits = {"Hearts", "Clubs", "Spades",…arrow_forwardAnswer the given question with a proper explanation and step-by-step solution.arrow_forwardType two statements using nextInt() to print two random integers between (and including) 0 and 9. End with a newline. Ex: 7 Note: For this activity, using one statement may yield different output (due to the interpreter calling randGen.nextInt() in a different order). Use two statements for this activity. (Notes) 1 import java.util.Scanner; 2 import java.util.Random; 3 4 public class DiceRoll { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); = new Random(); 5 6. 7 Random randGen 8 int seedVal; 9. 10 seedVal = scnr.nextInt(); 11 randGen.setSeed(seedVal);arrow_forward
- public class utils { * Modify the method below. The method below, myMethod, will be called from a testing function in VPL. * write one line of Java code inside the method that adds one string * to another. It will look something like this: * Assume that 1. String theInput is 2. string mystring is ceorge неllo, пу nane is * we want to update mystring so that it is неllo, пу nane is Ceorge */ public static string mymethod(string theInput){ System.out.println("This method combines two strings."); Systen.out.println("we combined two strings to make mystring); return mystring;arrow_forwardA bank account earns interest once per year. Compute the interest earned in the first and second years.arrow_forwardCan you do it in Javaarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education