Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is one problem just with multiple parts. I need all parts answered. Thank you! Part 1 Suppose you find a magic $1.00 coin. Its

image text in transcribedimage text in transcribedThis is one problem just with multiple parts. I need all parts answered. Thank you!

Part 1 Suppose you find a magic $1.00 coin. Its magic power is as follows: as each day passes, you get an additional dollar plus half of what you already had it appears by the window somehow). Write a method called getRichQuick (no input is necessary for this method) that prints the first n days while your total is less than $1,000,000 dollars. In other words, how many days does it take for you to earn $1,000,000? Your program should calculate these numbers and print the following output: Day 1: $1 Day 2: $1 + ($1 + .50) = $2.50 Day 3: $2.50 + ($1 + 1.25) = $4.75 Day N: $x + ($1 + Y) = $1888888 Part 2 Write a method called eTaylor that takes as input (i.e. argument) a double x and returns the value of ep. This method should NOT use any Math library functions, so you will need to use Taylor Series for ex (loop until terms become close to O, say 10e-16): el = 1+2+ + 23 2! 3! + Hint: Write a helper method for finding the nth power of a number x, divided by n! = n.(n-1) (n 2).....2.1 that is, your helper method should accept an x and output your method eTaylor will return the value of = 0 n! Part 3 Hint: User will enter certain number of random words, you need to read the input as string and evaluate based on the following instructions. Write a void method called palindromeCheck that takes NO argument. The method should have functionality to check whether or not the word is a palindrome and print to the screen all of the palindromes, one per line. Also, the last line of the output should have the message: "There are x palindromes out of y words provided by user" (where x is the number of palindrome words detected, and y is the total number of words entered by user). Hint: for this lab exercise you will need the following methods on String objects: length() gives the length of a string (that is, the number of characters it contains) and charAt(i) - gives the character at position i. For example: int sizeofString = "bob".length) // should be 3 char firstChar = "bob".charAt(0) // should be 'b' Part 4 In main, write a menu that allows a user of your program to select and run the programs you wrote in the methods above. The user should be able to play with your methods a many times as they want and only exit the program if they want to exit. For example: Welcome to Lab5! Enter 1 to check how long it takes to get rich on a magic dollar coin. Enter 2 to calculate e^x for any real x. Enter 3 enter palindrome words. Enter 4 to re-print the menu. Enter O to exit. What is your choice? 2 Enter an x: 1 e^1 = 2.7182818284590452 What is your choice? Thanks for participating! Goodbye. Note that the method from part 2 did not have you asking for keyboard input. Do NOT go back and modify your method from part, instead handle the request for keyboard input (to get the x or all the words) in main after the user has made his/her choice (i.e. item 2 or 3 in the menu). Part 5 Debugging Debugging your code is a valuable time-saving and problem-solving technique, and is easy to do in both BlueJand Eclipse. Learn how to set a breakpoint (usually in the "gutter" of the code window, a column to the left) in your software and how to execute your code in "debug mode" so that your software pauses execution at each breakpoint. Using this technique, one can pause execution and inspect the values of variables. Debug any of the previous code you have written in this lab, and determine intermediate values of loop variables as they execute

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions