+1-415-315-9853

info@mywordsolution.com

## Programming

 C/C++ Java DOT NET Python Assembly C Sharp Perl COBOL Visual Basic CAD/CAM Object Oriented Programming Asp.NET PHP JSP Shell Scripting Java Script Ajax CSS/HTML Joomla Wordpress Megento Photoshop DBMS PL-SQL Oracle MS-SQL MS-ACCESS My-SQL SYBASE FOXPRO Excel Programming Language Mobile Applications

Purpose of this asignment: Practice for number basis transformation.

Task 1: Solve the following exercises

A) Convert the following numbers (from base 10) to base 2:

•    13
•    85
•    219
•    511
•    512

B) Convert the following numbers (from base 2) to base 10. You should assume they are all positive values:

•    1010
•    10001
•    11011
•    0111011
•    01010101

C) Convert the following numbers:

•    7A1 (base 16) to: base 10
•    567 (base 8) to : base 5
•    567 (base 10) to : base 5
•    2121 (base 3) to : base 4
•    7778 (base 10) to: base 16

D) Convert the following negative numbers (from base 10) to base 2 using 2's complement on 8 bits:

•    -1
•    -13
•    -59
•    -83
•    -128

E) Convert the following numbers (from base 2) to base 10. This binary representation is using 2's complement on 8 bits to represent negative numbers:

•    10101010
•    10011010
•    11001001
•    10001000
•    01111111

prepare a program that allows the user to convert numbers between any 2 basis. Your program should follow the requirements:

A) Your program should support all the basis between 2 and 16 inclusively.

B) It should loop and repeatdly take user input and perform the following operations (shown also in the sample run below): exit the menu, convert a number from any base to any other base, print a file, solve a file.

C) The repetition over the menu options should be implemented using a loop, not recursive calls to main.

D) If a number does not have a not valid representation for the basis that it is represented in, the program should indicate that (by printing a message). It should not crash and should also not work with the number. E.g. see the behavior:

E) Enter a number, current_base, new_base(e.g.: 129,10,2): 127,7,10

F) Invalid representation n =  127  in base: 7

G) The program should be able to perform multiple conversions specified in a 'test file'. Here the 'test file' has the meaning of a 'homework file'. It specifies a set of exercises to be solved. In particular, each line of the file specifies a number and the basis it is written in and a set of other basis to be converted to. The program should be able to read all the lines in such a file, solve each line and prepare the result in another file. The line format is:

H) current_base : number, new_base_1, new_base_2, ..., new_base_M

I) The answer for a line in the format above should include the number representation for each of the new bases:

J) current_base : number, new_base_1: number_1, new_base_2: number_2, ..., new_base_M : number_M

Notice in the ex above that collons separate the base from the number and commas separate pairs of base and number.

K) Your files (both the test and the solution) should follow the format indicated above.

L) If the number representation is wrong in the test file, the program should also indicate that in the solution file.

M) Your program should work for other test files with more or less basis transformations per line.

N) Your program should work name the solution file based on the test file name, by appending '_solution' to the filename (still with extension '.txt'). For ex in my sample run I used the file 'test1.txt' and I hase saved the answers to a file named 'test1_solution.txt'.

O) You can organize your solution however you want. I recommend writting a function for each of the following operations:

• Test that a number is valid for the base it is represented in: it contains no illegal symbols. E.g. of bad representations: 127 (in base 7), 1G (in base 16), 1A (in base 10 or less).
• Convert from base 10 to any other base. This function should take all the arguments it needs: number, new base.
• Convert from any base to base 10
• A function (or at least a structure) to map from symbols to values (e.g. 'A' is 10, 'B' is 11, ..., 'F' is 15).
• Afunction (or at least a structure) to map from values to symbols (e.g. 10 is 'A', 11 is 'B', ..., 15 is 'F').

P) Consider how you want to represent a number (since you have to process it symbol by symbol)

Q) The test file and the solution produced for it in the sample runs are: test1.txt , and test1_solution.txt

Python, Programming

• Category:- Python
• Reference No.:- M94779

Have any Question?

## Related Questions in Python

### Introductionthe assignment is to design a service oriented

Introduction The assignment is to design a Service Oriented Architecture-based solution for a given domain. You must show a good understanding of Service Oriented principles. In addition you must show knowledge and under ...

### Python assignmentwrite a python program to crack a password

Python Assignment Write a Python program to crack a password in the Linux /etc/shadow file. Write a program using Python to implement a password cracker for Linux. You should utilize a dictionary (small - English) to cra ...

### Problem descriptionthe previous assignment assumes its

Problem Description The previous assignment assumes its input includes spaces between every token in an expression, but many programmers tend not to use so many spaces, if the expression is unambiguous. For example, both ...

### Programming assignments1read python tutorial

Programming Assignments 1. Read Python Tutorial (https://docs.python.org/3/tutorial/index.html) sections 4.6 to 4.8. 2. Write a Python function that checks whether a passed string is palindrome or not. Note: A palindrome ...

### Project add time and object interaction to the

Project: Add Time and Object Interaction to the Simulation Addendums Addendums to the project will be posted at: https://www.cs.uoregon.edu/Classes/16S/cis211/Projects/P4/P4.html This specification is very detailed, and ...

### 1 read python tutorial httpsdocspythonorg3tutorialindexhtml

1. Read Python Tutorial (https://docs.python.org/3/tutorial/index.html) sections 1 to 4.5. 2. Write a Python program that prints out a table of values of all even powers of 2 from 2**0 through 2**32. For each value, prin ...

### 1 alternating sumsprovide code for an integer-valued

1. Alternating sums Provide code for an integer-valued function altSumSquares(n) that calculates and returns as its value the alternating sum of the squares of the first n positive integers. You may not use a formula to ...

### Write python code to solve the following problem1 write a

Write Python code to solve the following problem: 1. Write a Python program that prompts the user for his/her amount of money, then reports how many Nintendo Wiis the person can afford, and how much more money he/she wil ...

### Python homeworkyou will write a program that acts like a

Python HomeWork You will write a program that acts like a simple calculator for binary numbers. You should read in a string of input that has the format: number operator number. Each of the numbers should be presented in ...

### You have all experienced how when you are typing a text

You have all experienced how when you are typing a text message the application will provide potential words that complete what you are typing (and sometimes insist on completing them incorrectly). You will write a Pytho ...

• 4,153,160 Questions Asked
• 13,132 Experts
• 2,558,936 Questions Answered

## Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

### A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

### What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

### Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

### Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

### Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate