A number with a base other than 10 can be written using its base as a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A number with a base other than 10 can be written using its base as a subscript. For example, 10112 represents the binary number 1011 which can be converted to a base 10 number as follows: (1 * 20) + (1 * 2¹) + (0*2²) + (1 * 2³) = 1+2+0+ 8 = 1110 Similarily, the base 3 number 1123 can be converted to base 10 as follows: (2*30) + (1 * 3¹) + (1 * 3²) = 2 + 3 + 9 = 1410 and the base 8 number 325g can be converted to base 10 as follows: Write a program that reads two numbers from a user. The first input is the number to be converted into base 10, and the second input is the number's base (base of first input). The program determines if the number is a legal number in the given base. if its a legal number the program converts it into a number of a base 10, otherwise it prints the number is not a legal number of a give base. For example the number 3214 is a legal number because 321 is a legal base 4 number. However, since all digits of a base n number must be less than n, the following 3716 is not a legal base 6 number (the digit 7 is not allowed). Note: make sure you solve this question using while or for loop. It is not allowed to use the any external library to convert the input number into a base 10 number. Sample Program runs: Sample run #1 Enter a number: 14732 Base: 6 The input number is not a legal number of a base 6 Sample run #2 Enter a number: 1111 Base: 2 Number in base 10: (1 X 1) + (1 X 2) + (1 X 4) + (1 X 8) = 15 Sample run #3 (5 * 80) + (2*8¹) + (3*8²) = 5 + 16 + 192 = 21310 Enter a number:-1243 Base: 5 Number in base 10: (3 X 1) + (4 X 5) + (2 X 25) + (-1 X 125) = -198 Sample run #4 Enter a number: 147 Base: 8 Number in base 10: (7 X 1) + (4 X 8) + (1 X 64) = 103 Sample run #5 Enter a number:one Error: the input value is not an integer number Sample run #6 Enter a number: 1245 Base: two Error: the input value is not an integer number A number with a base other than 10 can be written using its base as a subscript. For example, 10112 represents the binary number 1011 which can be converted to a base 10 number as follows: (1 * 20) + (1 * 2¹) + (0*2²) + (1 * 2³) = 1+2+0+ 8 = 1110 Similarily, the base 3 number 1123 can be converted to base 10 as follows: (2*30) + (1 * 3¹) + (1 * 3²) = 2 + 3 + 9 = 1410 and the base 8 number 325g can be converted to base 10 as follows: Write a program that reads two numbers from a user. The first input is the number to be converted into base 10, and the second input is the number's base (base of first input). The program determines if the number is a legal number in the given base. if its a legal number the program converts it into a number of a base 10, otherwise it prints the number is not a legal number of a give base. For example the number 3214 is a legal number because 321 is a legal base 4 number. However, since all digits of a base n number must be less than n, the following 3716 is not a legal base 6 number (the digit 7 is not allowed). Note: make sure you solve this question using while or for loop. It is not allowed to use the any external library to convert the input number into a base 10 number. Sample Program runs: Sample run #1 Enter a number: 14732 Base: 6 The input number is not a legal number of a base 6 Sample run #2 Enter a number: 1111 Base: 2 Number in base 10: (1 X 1) + (1 X 2) + (1 X 4) + (1 X 8) = 15 Sample run #3 (5 * 80) + (2*8¹) + (3*8²) = 5 + 16 + 192 = 21310 Enter a number:-1243 Base: 5 Number in base 10: (3 X 1) + (4 X 5) + (2 X 25) + (-1 X 125) = -198 Sample run #4 Enter a number: 147 Base: 8 Number in base 10: (7 X 1) + (4 X 8) + (1 X 64) = 103 Sample run #5 Enter a number:one Error: the input value is not an integer number Sample run #6 Enter a number: 1245 Base: two Error: the input value is not an integer number
Expert Answer:
Answer rating: 100% (QA)
Python code def checknumbase aintnum convert string to integer bintbase conv... View the full answer
Related Book For
Managerial Economics
ISBN: 978-1118808948
8th edition
Authors: William F. Samuelson, Stephen G. Marks
Posted Date:
Students also viewed these computer engineering questions
-
Terri Ann Masters, Vice President of Sales for Startech Corporation, was wrestling with a critical issue related to one of her longtime and, until recently, most talented salespeople, Jason Benjamin....
-
As vice president of sales for a rapidly growing company, you are grappling with the question of expanding your direct sales force (from its current level of 60 national salespeople) by hiring 5 to...
-
The vice president of sales for Blasterman Cosmetics, Inc. believes that 40% of the company's orders come from customers who are less than 30 years old. A random sample of 10,000 orders will be used...
-
iHerb Inc. has several herb extractor evaporators that were purchased four years ago at a price of $20,000. These machines currently require annual maintenance costs of $2,000. However, the...
-
The Ladies Professional Golfers Association (LPGA) maintains statistics on performance and earnings for members of the LPGA Tour. Year-end performance statistics for the 30 players who had the...
-
A series \(R L C\) circuit consists of a \(280 \Omega\) resistor, a \(25 \mu \mathrm{H}\) inductor, and an \(18 \mu \mathrm{F}\) capacitor. What is the rms current if the emf is supplied by a...
-
Prepare ledger account forms like the ones in Exhibit 5 for the following accounts: Cash (111), Accounts Receivable (113), and Service Revenue (411). Post the transactions that are recorded in SE 9...
-
Daphne Kavier is the managing director of the Topeka Day Care Center. Topeka is currently set up as a full-time child care facility for children between the ages of 12 months and 6 years. Daphne is...
-
San Antonio Chair Inc. has direct labor cost standard of $ 1 4 per direct labor hour and an efficiency standard of 6 hours per chair. The actual results for the period when 3 0 chairs were built were...
-
Zev enters it a contract with Aerin to buy Aerin's boat for $2,500. Zev tells Aerin he plans to use the boat to charge people to travel around the harbor to look at the Christmas lights. Zev has done...
-
It is not uncommon for a career firefighter to obtain 10 or more certificates depending on their career progression. Do you think this is overkill or exactly what the profession needs? discuss your...
-
The accounts of bigbucks show that they have vehicles with historic costs of $ 6 0 0 , 0 0 0 and the accumulated depreciation balance is $ 2 0 0 , 0 0 0 . The depreciated vehicles using the reducing...
-
Describe the exchange rate system used by various governments? please explain thoroughly thanks
-
A potential client comes to you about working with you on a financial planning engagement and is with an advisor currently who only holds his Series 6, 63, and 7 licenses. This potential client wants...
-
11. (4 points) Concord Company had bonds outstanding with a face value of $400,000. On April 30, 2017, when these bonds had an unamortized discount of $35,000, they were called in at 103. To pay for...
-
Because existing staff are fully scheduled, if the firm is awarded the contract, it must hire one new staff member at a salary of $52,000 to handle the additional workload. The managing partner is...
-
11. [-/5 Points] DETAILS HARMATHAP12 10.2.029. MY NOTES PRACTICE ANOTHER Use the graph shown below and identify points from A through I that satisfy the given conditions. 10 - y = f(x) SH 10 (a)...
-
The relationship described in question 7 does not always appear to hold. What factors, besides the number of firms in the market, might affect margins?
-
A firms production function is given by the equation Q = 12L. 5 K. 5 , Where L, K, and Q are measured in thousands of units. Input prices are 36 per labor unit and 16 per capital unit. a. Create a...
-
Walt Disney Pictures vowed it would learn from its mistakes after suffering a loss of more than $100 million on the film John Carter. (The studio had ceded creative control to a maverick director,...
-
In 2010, the California utility, PG&E (formerly, Pacific, Gas, and Electric) suffered a fatal gas pipeline explosion in San Bruno. The company was found to have inadequate inspection and safety...
-
Use the following accounts and balances to prepare a balance sheet with the accounts in proper order for Anatole Company at June 30, 20x6, using Exhibit 3 as a model: Accounts Receivable $1,600 Wages...
-
Match the terms below with the descriptions in the list that follows: a. The recording of all business transactions in terms of money b. A process by which information is exchanged between...
-
Develop a brief answer to each of the following questions. 1. How are expenses and dividends similar, and how are they different? 2. In what ways are CVS and Southwest Airlines comparable? Not...
Study smarter with the SolutionInn App