Write a program that prompts the user to enter a positive integer value, and compute the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that prompts the user to enter a positive integer value, and compute the following sequence: ● If the value is even, halve it. If it's odd, multiply by 3 and add 1. Repeat this process until the value is 1., printing out each value Finally print out how many of these operations you performed. . Note: If the input value is less than 1., print a message containing the word Error and exit the program. You can assume that the input will have smaller than 200 operations. This is how the output should look like: ● . Initial value 18: 9 Bext valde 18: 28 Hext value is: 14 Next value ist liext value 18: 2ext value MO M Next value Le: 35 Next value is: 17 Next value an: 52 Next value La: 26 Next value is: 13 Next value is: 40 Next value is: 201 Next value is: 10 Next value is: 5 Next value is: 16 Next value is: 8 Next value is: 4 Next value is: 2 Final value 1, number of operations performed 19 Write a program that prompts the user to enter a positive integer value, and compute the following sequence: ● If the value is even, halve it. If it's odd, multiply by 3 and add 1. Repeat this process until the value is 1., printing out each value Finally print out how many of these operations you performed. . Note: If the input value is less than 1., print a message containing the word Error and exit the program. You can assume that the input will have smaller than 200 operations. This is how the output should look like: ● . Initial value 18: 9 Bext valde 18: 28 Hext value is: 14 Next value ist liext value 18: 2ext value MO M Next value Le: 35 Next value is: 17 Next value an: 52 Next value La: 26 Next value is: 13 Next value is: 40 Next value is: 201 Next value is: 10 Next value is: 5 Next value is: 16 Next value is: 8 Next value is: 4 Next value is: 2 Final value 1, number of operations performed 19
Expert Answer:
Answer rating: 100% (QA)
mainpy 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 try initialvalue intinputInitial value is if ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Develop a evaluation report analyzing the frameworks for evaluating the impact of an information system and system change. Develop an Excel or Word table evaluation plan for the project. The first...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
31% of American adults surveyed stated that giving up their phone for a day would be more difficult than giving up their significant other. In 2012, the United States population over the age of 18...
-
Find steady state current i of a RL circuit with L=2 H and R=892 which can be modeled by the following differential equation: 2di/dt+8i=v(t) where v(t) = 16 cos(10t -45) with phasor technique. Also...
-
A couple plan to have two children and want to know the probability of having one boy and one girl. (a) Does {0, 1, 2} represent an equiprobable sample space for finding the probability of exactly...
-
The CDG Carlos, Dan, and Gail Partnership has decided to liquidate as of December 1, 20X6. A balance sheet on the date follows: Additional Information 1. Each partners personal assets (excluding...
-
What do systems interact with?
-
Bed and Breakfast (B&B), an Italian company operating in the Tuscany region, follows IFRS and has made the choice to remeasure long-lived assets at fair value. B&B purchased land in 2009 for 150,000....
-
5. Create a flowchart that shows how to log in an account in social media (Facebook page) using a correct user-defined User ID and Password. (15 pts.) Legends: EmailID = Email ID pass = password
-
As the accountant for Runson Moving Company, you are preparing the companys annual return, Form 940 and Schedule A. Use the following information to complete Form 940 and Schedule A on pages 5-40 to...
-
What is VALS and what are its components? Provide some examples and works cited?
-
Consider the system of Fig. P7.2-5 with T = 1 s . Let the digital controller be a variable gain K such that D(z) = K . Hence m(kT) = Ke(kT). (a) Write the closed-loop system characteristic equation....
-
In its Annual Report for the year ended 31 December 2013, IHH Healthcare Berhad, a Malaysian listed company disclosed that it had adopted Malaysian Financial Reporting Standard (MFRS) 10,...
-
Jill, the CEO of Redmond Medical Center, and her assistant, Joe, attended the American College of Healthcare Executives (ACHE) annual Congress last week and, upon comparing notes, they concurred that...
-
Brian Willard, who lives in Denver, just read a lengthy article about Redbeacon, the subject of Case 13.1. Hes thinking about launching a Web-based service similar to Redbeacons. Brian just inherited...
-
What basic questions should you ask yourself in deciding on the best GUI control to use for each data attribute to be captured and input? Provide examples of data attributes, and instructions on...
-
Gregory's age is 5 years greater than (1)/(3) of Amanda's age. Gregory is 17 years old. If Amanda's age is denoted by x, which equation represents this situation and how old Is Amanda?
-
Assume you are the accountant for Catalina Industries. John Catalina, the owner of the company, is in a hurry to receive the financial statements for the year ended December 31, 20X1, and asks you...
-
In 2012, Margaret and John Murphy are married taxpayers who file a joint tax return with AGl of $25,000. During the year they incurred the following expenses: Hospitalization insurance...
-
William sold Section 1245 property for $25,000 in 2012. The property cost $35,000 when it was purchased 5 years ago. The depreciation claimed on the property was $16,000. a. Calculate the adjusted...
-
Mallory Corporation has a calendar year-end. The corporation has paid estimated payments of $10,000 during 2012 but still owes an additional $5,000 for its 2012 tax year. a. When is the 2012 tax...
-
A printed circuit board of mass \(1 \mathrm{~kg}\) is supported to the base through an undamped isolator. During shipping, the base is subjected to a harmonic disturbance (motion) of amplitude \(2...
-
An electronic instrument of mass \(10 \mathrm{~kg}\) is mounted on an isolation pad. If the base of the isolation pad is subjected to a shock in the form of a step velocity of \(10 \mathrm{~mm} /...
-
A viscously damped single-degree-of-freedom system has a body of mass \(25 \mathrm{~kg}\) with a spring constant of \(70 \mathrm{kN} / \mathrm{m}\). Its base is subjected to harmonic vibration. (a)...
Study smarter with the SolutionInn App