Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description When you want to knit an object by hand you purchase a pattern and yan. The pattern tells you how to perform the knitting

image text in transcribed

Description When you want to knit an object by hand you purchase a pattern and yan. The pattern tells you how to perform the knitting and how much yarn is needed to knit the object in the yarn that the designer used. Yarn comes in balls. Each ball of yarn has a gven number of yards, but this number varies from one type of yarn to another. It can be impossible to find the same yarn that the pattern calls for, so you aften must perform a substitution. Suppose that you were supposed to use S balls of Chunky Alpaca that comes in 237 yard balls, but instead need to use Big and Fluffy, which comes in 315 yard balls You need: 237 5 yards to complete the project which is 1185 yards of yarn. This would be 3.76 balls of Big and Fluffy. This means you'll need to purchase 4 balls of Big and Fluffy to complete the project. If you have a partial ball, you must purchase it because otherwise you run out of arn. Nothing spoils knitting like running out of yarn. You are to write a program that takes the necessary data and performs the computation above. The interaction of the program is shown below. The letters in bold type were entered by the user Enter the nase of the first type of yarn Chunky Alpaca Enter the nusber of yards per bali of yarn The nusber of yards per ball aust be positive, please re-enter The nuber of balls ust be positive, please re-enter Enter the nase of the substituted yarn Big and Fluffy Enter the nusber of yards per bali The nusber of yards per ball aust be positive, please re-enter You should purchase 4 balls of Big and Fluffy instead of 5 of Chunky Alpaca Notice the error checking that is being done. If the value of any of the integer variables is non positive the user should be given one chance to enter them again. Input Advice Yarn names can be made up of multiple words. This will determine whether you should use the psxt method of the oextioeil method The number of yards of yarn in a ball is always gven using whole numbers-no decimal places are used. When you read in a mixture of integers and Strings, something bad can happen with newline characters. The pextiat command leawes the neline character at the end of the line. This character alone will be found if a extioe) command is called uppose we have a Scanner called input that has been declared and constructed If we are trying to read in a String (one a line by itselfl, then an integer on a line by itself and another String on the next line, input could be: Those newine characters are what are recorded when Enter is pushed on the keyboard

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

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions