Consider the question in Exercise R1.13. Suppose the numbers ($10,000, 6 percent, $500) were user selectable. Are there values for which the
Write an algorithm to settle the following question: A bank account starts out with $10,000. Interest is compounded monthly at 6 percent per year (0.5 percent per month). Every month, $500 is withdrawn to meet college expenses. After how many years is the account depleted?
Trending nowThis is a popular solution!
Chapter 1 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Using MIS (10th Edition)
- The Fibonacci algorithm is a famous mathematical function that allows us to create a sequence of numbers by adding together the two previous values. For example, we have the sequence:1, 1, 2, 3, 5, 8, 13, 21…Write your own recursive code to calculate the nth term in the sequence. You should accept a positive integer as an input, and output the nth term of the sequence.Once you have created your code, add comments describing how the code works, and the complexity of any code you have created.arrow_forwardWrite a program that draws a square fractal. Fractals are images that keep repeating their own image in ever-smaller versions. There exists numerous fractals and some fractals rely on computation of advanced mathematics. All fractals have a recursive quality and provide an ideal platform for practicing recursive concepts. You will note that from the four corners of the center rectangle, smaller rectangles are drawn and each rectangle in turn continues to draw three smaller rectangles until the rectangle is the size of one pixel. A CODE TEMPLATE & PICTURE OF OUTPUT IS ALREADY PROVIDED IN THE ATTACHED PICTURES Method drawSquare1 gets the ball rolling and draws a solid rectangle in the center of the screen. The initial rectangle needs to be 1/4 the size of the monitor. This explains why it is important to know the screen resolution and why this information is passed by parameter. Method drawSquare1 needs to make four method calls to draw each one of the four rectangles attached to…arrow_forwardWrite a program that asks users when their birthday is. Use information provided to give them their astrological sign. Each of the twelve signs should display a different horoscope. Use the following dates for each sign, keeping in mind that both month and day must be evaluated for an accurate result. Aries: March 21–April 20 Taurus: April 21–May 21 Gemini: May 22–June 21 Cancer: June 22–July 22 Leo: July 23–August 22 Virgo: August 23–September 23 Libra: September 24–October 23 Scorpio: October 24–November 22 Sagittarius: November 23–December 21 Capricorn: December 22–January 20 Aquarius: January 21–February 19 Pisces: February 20–March 20arrow_forward
- Correct answer will be upvoted else downvoted. Computer science. You are given an integer n. Check if n has an odd divisor, more noteworthy than one (does there exist such a number x (x>1) that n is separable by x and x is odd). For instance, assuming n=6, there is x=3. Assuming n=4, such a number doesn't exist. Input The primary line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow. Each experiment contains one integer n (2≤n≤1014). If it's not too much trouble, note, that the input for some experiments will not squeeze into 32-cycle integer type, so you should use no less than 64-digit integer type in your programming language. Output For each experiment, output on a different line: "Indeed" if n has an odd divisor, more noteworthy than one; "NO" in any case. You can output "YES" and "NO" regardless (for instance, the strings yEs, indeed, Yes and YES will be perceived as certain).arrow_forwardWrite a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia Partially done code (C++): #include <vector>#include <string>#include <iostream> using namespace std; // TODO: Write method to create and output all permutations of the list of names.void AllPermutations(const vector<string> &permList, const vector<string> &nameList) { } int main(int argc, char* argv[]) {vector<string> nameList;vector<string> permList;string name; // TODO: Read in a list of names; stop when -1 is read. Then call recursive method.return 0;}arrow_forwardWrite a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia partial code below, only lines 9-11, and 18 can be added onto, the rest must stay the same. #include <vector>#include <string>#include <iostream> using namespace std; // TODO: Write method to create and output all permutations of the list of names.void AllPermutations(const vector<string> &permList, const vector<string> &nameList) { } int main(int argc, char* argv[]) { vector<string> nameList; vector<string> permList; string name; // TODO: Read in a list of names; stop…arrow_forward
- Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia main.cpp #include <vector>#include <string>#include <iostream> using namespace std; // TODO: Write method to create and output all permutations of the list of names.void AllPermutations(const vector<string> &permList, const vector<string> &nameList) { } int main(int argc, char* argv[]) {vector<string> nameList;vector<string> permList;string name; // TODO: Read in a list of names; stop when -1 is read. Then call recursive method.return 0;}arrow_forwardSuppose you're programming a robot to do common tasks around your home, and you write a recursive routine that will allow it to empty a vase of flowers. Which of the following most closely resembles the behavior you would expect from your robot while it's executing that recursive routine? O Your robot smashes the vase of flowers against the ground and then gets a broom to clean up the mess. O Your robot smashes the vase of flowers against the ground and then goes to the other room to sharpen your kitchen knives. O Your robot takes a fistful of flowers out of the vase, peers inside, and then turns the vase upside down to dump out all the water. O Your robot observes the flowers. Then your robot gently strokes the flowers. Finally, your robots eats the flowers. O Your robot hides in a broom closet, terrified of the prospect of another nasty run-in with your wifi-enabled smart toaster. O Your robot takes all the flowers out at once and disposes of them quite efficiently. Your robot starts…arrow_forwardUsing Dart. Create a program that will play the “cows and bulls” game with the user. The game works like this: Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit the user guessed correctly in the correct place, they have a “cow”. For every digit the user guessed correctly in the wrong place is a “bull.” Every time the user makes a guess, tell them how many “cows” and “bulls” they have. Once the user guesses the correct number, the game is over. Keep track of the number of guesses the user makes throughout the game and tell the user at the end.arrow_forward
- Substitution ciphers are encryption/decryption algorithms that replace one letter or number with another. The first attested use of a substitution cipher in military affairs was by Julius Caesar, described by him in Gallic Wars (cf. Kahn pp83-84). In caesar cipher , you replace each letter by 3rd letter on. If it is out of bound (later than Z), then round to the head (letter A) and continue the shift. For example:meet me after the toga party PHHW PH DIWHU WKH WRJD SDUWB Please write a program in Java to implement the Caesar Cipher: a. Implement the encryption algorithm. Ask the user to input one all lower case normal sentence (called plaintext) using the nextLine method, and then output the encrypted text (called ciphertext). b. Implement the decryption algorithm. Ask the user to input one encrypted sentence (i.e. ciphertext) using the nextLine method, and then output the decrypted text (i.e. plaintext).arrow_forwardIn python, Problem Description:Sheldon and Leonard are physicists who are fixated on the BIG BANG theory. In order to exchange secret insights they have devised a code that encodes UPPERCASE words by shifting their letters forward. Shifting a letter by S positions means to go forward S letters in the alphabet. For example, shifting B by S = 3 positions gives E. However, sometimes this makes us go past Z, the last letter of the alphabet. Whenever this happens we wrap around, treating A as the letter that follows Z. For example, shifting Z by S = 2 positions gives B. Sheldon and Leonard’s code depends on a parameter K and also varies depending on the position of each letter in the word. For the letter at position P, they use the shift value of S = 3P + K. For example, here is how ZOOM is encoded when K = 3. The first letter Z has a shift valueof S = 3 × 1 + 3 = 6; it wraps around and becomes the letter F. The second letter, O, hasS = 3 × 2 + 3 = 9 and becomes X. The last two letters…arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. You have two positive integers an and b. You can perform two sorts of tasks: a=⌊ab⌋ (supplant a with the integer part of the division among an and b) b=b+1 (increment b by 1) Track down the base number of activities needed to make a=0. Input The primary line contains a solitary integer t (1≤t≤100) — the number of experiments. The main line of the depiction of each experiment contains two integers a, b (1≤a,b≤109). Output For each experiment, print a solitary integer: the base number of activities needed to make a=0.arrow_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