Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: To give you more practice working with arithmetic operators, and methods in the Math and Random classes, Part A: Sarah made the rookie mistake

image text in transcribed
image text in transcribed
image text in transcribed
Objective: To give you more practice working with arithmetic operators, and methods in the Math and Random classes, Part A: Sarah made the rookie mistake of walking into Titan Bakery with a $200 bill, and nothing smaller. She has bought some delicious bagels, biscuits, muffins and rolls, and now the cashier needs to make change. The cashier has $50's, $20's, $10's. $5's and $1's and will naturally dispense the $50's first, the $20's second, and so on. In this program, you will a) ask the user how much Sarah spent on food (between 0-200), and then b) print out how many of each denomination ($50, $20, $10, $5 and $1) should be dispensed. For example, if Sarah spent $67 on food, the change, $133, would be administered as 2 $50's, 1 $20,1 $10,0 $5's, and 3 $1's (2-50 - 120 + 1-10 +0'5 +3'1 == 133). Hint: think about how many $50's go into $133, and then how much will be left over. Instructions: 1. Add a Java class. Change, to a BlueJ project. Lab3. 2. Customize the multiline comment at the top of Change, and the README. 3. Write an algorithm, just in English, describing step by step how you will solve this problem. List the steps in the README. 4. Implement your algorithm in Change, adding the steps of the algorithm to your code, as we did in the last lab 5. Make sure you indentation is consistent, and your spacing is as well. Choose good, descriptive identifier names, 6. Test your algorithm using a variety of inputs (making sure, of course, that you know what the output should be Sample Output (user input is in bold): Titan Bakery bill: 567 Change: $133 # 50's: 2 # 20's: 1 # 10's: 1 # 5's: 0 #1's: 3 Page 1 of 3 Part B: The Fibonacci sequence is a sequence of numbers in which each term is the sum of the two that precede it: 1, 1, 2, 3, 5, 8, 13, 21, 34,55,- So, 2 = 1 +1:31 +2:5 = 2 +3; etc. We number these, so f1. 1. 13-2, 3, ts=5, and in general the nth term fn = f1 + f2 Interestingly we can find the nth term, to using a formula: (on - (1-4)") fn= 15 where that mysterious looking o symbol (the Greek letter Phi) is a constant called the Golden Rectangle, with a value of (1+5) p= \ For example, if n-6, then te = (1.6180 - (1-1.6189/V5 - 7.9999999988 (which is quite close to 8) Now that we are experts on the Fibonacci sequence (except maybe how to spell it, let's write a program to calculate it. To add excitement, instead of asking the user for n, we will ask the user for a minimum and a maximum value for n your program will generate a random number for n between minimum and maximum, inclusive, and use that to calculate in Sample Output: Minimum n: 1 Maximum n: 10 Computing 15 f5 is 5 Minimum n: 3 Maximum n: 8 Computing 17 17 is 13 Instructions: 1. Create a new Java class in your Lab3 Blue, Fibo Maker 2. Customize the multiline comment in FiboMaker as before. 3. Be sure and comment your code properly 4. Since we use phi repeatedly, it is better to calculate it just once, and store it in a constant 5. Your program will need to use the Math and Random classes 6. Be sure and test your program multiple times PHOB 2 ota Deliverables: To complete this lab, do four things: Complete the checklist below Demonstrate to either the Lab Assistant or the instructor prior to lab or during office hours. Submit your entire Lab (zip the entire project) and upload it to Canvas Separately upload a screenshot (do not zip it as part of your project) showing the output, using the values specified in the sample output section Checklist (not to hand in): Auto-layout applied? (command-shift- or ctrl-shift-1) Comment block filled in? (Name, Date, Description) README filled in (with the algorithm for part A) Descriptive identifier names chosen? (a.c, se, and st will get a 0 for sure) Redundant parentheses removed? -- e.g., a (bc). (de); or worse a = 1bc) + (de)); Both should be written abc + d'e: Spelling/spacing checked? Your output should match mine. Appropriate blank lines in the code to aid legibility? (0.9., 1 blank line separating input processing and output) Defined variables for any calculation? (Don't just print the formula in the System.out.printin statement) Uploaded project? (even if you've demoed, you still need to upload project) Uploaded separate screenshot of output? Read this checklist

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

1. Select the job or jobs to be analyzed.

Answered: 1 week ago