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...
-
Leslie Nunamaker owns a portfolio whose market model is expressed as rp = 1.5% + 0.90r1, + pl If the expected return on the market index is 12%, what is the expected return on Leslie's portfolio?
-
The solvent in a dilute solution follows (a) Henry's law (b) Dalton's law (c) Raoult's law (d) None of these.
-
List key principles and attributes of the value management (VM) approach.
-
Kathleen McFaddens restaurant in Boston has recorded the following data for eight recent customers:
-
What is the social location that determines this speech community? Is it determined by race, class, gender, sexuality, or some other social location? What makes this speech community unique? What are...
-
You are a profitable conglomerate thinking about getting into the gelati business by acquiring the firm Alati Gelati (AG). Current info for you, AG and their similar comp is listed below. You...
-
b) The flow in a rectangular channel of bed slope 0.0005 and n=0.02 is controlled at the upstream end by a sluice gate. At a certain time, the sluice gate was adjusted to discharge 7m'Is per meter...
-
Input: Ciphertext stored in four w-bit input registers A, B, C, D Number r of rounds w-bit round keys S[0;: : : ; 2r + 3] Output: Plaintext stored in A,B,C,D Procedure: Draw the special purpose...
-
Consider the following pseudo-code: for i=1 to n-1 do { // Assume i, j, k, n are integers for j=1 to i*i { k = 1; while (k < (n-i)) { perform ; k = k + 1; } } } Derive an expression for f(n), the...
-
Step 1: Choose one industry Choose one industry to research and analyze. Keep your topic focused on this single industry and the influence of NAFTA. Cars Electronics Agriculture You may propose a...
-
Problem 3: Presently, Able High Lift and Baker Overhead are the only suppliers of services that can lift heavy construction material to the heights required for high-rise construction projects the...
-
1. In the greater Stony Brook area there are many mom-and-pop pizza places. Despite their large number and great similarities in terms of costs and menus, each enjoy some degree of market power,...
-
A future patient/client of yours tells you that he has been very busy with school and work, and recently has only been sleeping 3-5 hours nightly. He explains that his schedule is so busy that there...
-
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...
-
Can you name five types of channels of communication?
-
How would you define your own leadership style? Do you have examples you can share with others on how you lead when called on?
-
Revisit the definition of strategic communication and then review the vignette at the beginning of the chapter. Match the different terms in the definition to the different entities in the vignette.
Study smarter with the SolutionInn App