Find Jobs
Hire Freelancers

Python Napier Calculator

$10-30 USD

完了済み
投稿日: 9年近く前

$10-30 USD

完了時にお支払い
This needs to be in Python. Problem statement For this program, you are to design and implement a calculator for positive integers that uses John Napier's location arithmetic (explained below). The user of your program will enter two numbers, using Napier's notation, and an arithmetic operator. You program is to translate these numerals into Hindu- Arabic decimal numbers, display them, perform desired operations, and finally print the result - in both abbreviated Napier's notation and in Hindu-Arabic decimal notation. The arithmetic operators that your program should recognize are +, -, *, and /. These operators are used to perform Python operations of integer addition, subtraction, multiplication, and division. The program is to be repeated as many times as the user wishes. You can not use import libraries. Input An input to your program will be interactive. Napier used letters to represent successive powers of 2, where a = 20, b = 21, c = 22, d = 23, ... z = 225. When converting to a decimal numeral you simply add the digits: abdgkl=20 +21 +23 +24 +26 +210 +211 =1+2+8+64+1024+2048=3147 His location numerals used sign-value notation, in which a number is simply the sum of its digits, where order does not matter, and digits can be repeated, e.g. abc = cba = bca abbc = acc = ad After each number or an operator is entered, you are to make sure that no illegal characters or arithmetic operators were entered. For numbers, an illegal character is anything that is not a letter. For operators, an illegal character is anything other than one of the four operator characters listed above. When an invalid input occurs, the program is not to crash or exit, but to ask the user for the given value again – until the valid values are entered. Output In addition to printing the decimal values of the two numbers entered by the user, you need to print the result of the operation in both notations. When printing in Napier's notation, make sure you do not repeat letters where a single letter would do, e.g. instead of abbc, you should print ad. In addition, if the result of your calculation is a 0, the equivalent string would be an empty string which we will not be able to see on the screen, so in such a case print a set of quotes, e.g. "". If the result of your calculations is a negative number, print the number with a minus sign in front, e.g. –abc. To represent a given decimal number as a location numeral, express it as a sum of powers of two and then replace each power of two by its corresponding digit (letter). For example, when converting from a decimal number: 87=1+2+4+16+64=20 +21 +22 +24 +26 =abceg You may find standard algorithms for converting from decimal to binary useful to achieve this purpose. To convert from a base-10 integer to its base-2 (binary) equivalent, the number is divided by two, and the remainder serves as the least-significant bit. The (integer) result is again divided by two, its remainder is the next least significant bit. This process repeats until the quotient becomes zero. Example: 13 / 2 = 6 R 1 6/2=3R0 3/2=1R1 1/2=0R1 So 13 in decimal is 1101 in binary which basically tells you to look at letters corresponding to where 1s occurred in the bit stream, which in this case means positions 0, 2, and 3 = acd Sample run Enter Napier's number: -ab2 Something is wrong. Try again. Enter Napier's number: abc The first number is: 7 Enter Napier's number: he lo Something is wrong. Try again. Enter Napier's number: hello The second number is 20,624 Enter the desired arithmetic operation: # Something is wrong. Try again. Enter the desired arithmetic operation: - The result is -20,617 or -adhmo Do you want to repeat the program? Enter y for yes, n for no:
プロジェクト ID: 7788103

プロジェクトについて

5個の提案
リモートプロジェクト
アクティブ 9年前

お金を稼ぎたいですか?

Freelancerで入札する利点

予算と期間を設定してください
仕事で報酬を得る
提案をご説明ください
登録して仕事に入札するのは無料です
アワード者:
ユーザーアバター
A proposal has not yet been provided
$25 USD 1日以内
5.0 (7 レビュー)
2.3
2.3
この仕事に5人のフリーランサーが、平均$27 USDで入札しています
ユーザーアバター
I teach algorithms and data structures using Java, python and c++. I can finish this project for you
$30 USD 1日以内
4.7 (113 レビュー)
6.5
6.5
ユーザーアバター
Interesting project. I have prior experience with Python and love for algorithms. Please consider for the project. Can discuss more details .
$50 USD 5日以内
2.8 (4 レビュー)
3.9
3.9
ユーザーアバター
A proposal has not yet been provided
$15 USD 5日以内
5.0 (1 レビュー)
1.0
1.0

クライアントについて

UNITED STATESのフラグ
Lynnwood, United States
5.0
15
お支払い方法確認済み
メンバー登録日:2月 11, 2014

クライアント確認

ありがとうございます!無料クレジットを受け取るリンクをメールしました。
メールを送信中に問題が発生しました。もう一度お試しください。
登録ユーザー 投稿された仕事の合計
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
プレビューを読み込み中
位置情報へのアクセスが許可されました。
あなたのログインセッションの有効期限がきれ、ログアウトされました。もう一度ログインしてください。