Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

10. For all of the following words, if you move the first letter to the end of the word, and then spell the result backwards

image text in transcribed

10. For all of the following words, if you move the first letter to the end of the word, and then spell the result backwards you will get the original word: banana dresser grammar potato revive uneven assess Write a method that reads a word and determines whether it has this property. Continue reading and testing words until you encounter the word quit. Treat uppercase letters the same as lowercase letters. Display how many words you found when you finish. 11. You have three identical prizes to give away and a pool of 10 finalists. The finalists are assigned numbers from 1 to 10 . Write a method to randomly select the numbers of 3 finalists to receive a prize. Make sure not to pick the same number twice. For example, picking finalists 3,6,2 would be valid but picking 3,3,11 would be invalid because finalist number 3 is listed twice and 11 is not a valid finalist number. For this problem you can insert the following line of code to generate a random number between 1 and 10 : int num = (int) ( Math.random ()10)+1; Notes: This project uses random numbers in a loop. You might wish to introduce the Random class instead of Math.random(). 12. Suppose we can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. We can redeem 6 coupons for one chocolate bar from the machine. This means that once you have started buying chocolate bars from the machine, you always have some coupons. We would like to know how many chocolate bars can be eaten if we start with N dollars and always redeem coupons if we have enough for an additional chocolate bar. For example, with 6 dollars we could consume 7 chocolate bars after purchasing 6 bars giving us 6 coupons and then redeeming the 6 coupons for one bar. This would leave us with one extra coupon. For 11 dollars, we could have consumed 13 chocolate bars and still have one coupon left. For 12 dollars, we could have consumed 14 chocolate bars and have two coupons left. Write a method that takes input for the value for N and outputs to the terminal how many chocolate bars we can eat and how many coupons we would have leftover. Use a loop that continues to redeem coupons as long as there are enough to get at least one chocolate bar. Submit your .java file to this page

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions