Find Jobs
Hire Freelancers

Build a Command Line Calculator in Objective C with precedence

$10-30 USD

キャンセル
投稿日: 約7年前

$10-30 USD

完了時にお支払い
Urgent help Needed to build simple and very small command line calculator, probably 2 hours of work for good programmers, please help guys I'm stuck on this simple project Specification You are to prepare a MacOS command-line tool that will act as a simple calculator. The a calculator will be run from the command line and will only work with integer numbers and the following arithmetic operators: + - x / % . The % operator is the modulus operator, not percentage. For example, if the program is compiled to calc , the following demonstrates how it will work ./calc 3 + 5 - 7 1 In the command line, the arguments are a repeated sequence in the form [number operator...] and ending in a [number] Hitting the enter key will cause the program to evaluate the arguments and print the result. In this case 1 . The program must follow the usual rules of arithmetic which say: 1. The x / and % operators must all be evaluated before the + and – operators. 2. Operators must be evaluated from left to right. For example, using Rule 1 becomes which results in 2+4*3-6 becomes 2+12-6 which result in 8 If we did not use Rule 1 then 2 + 4 x 3 – 6 would become 6 x 3 – 6 and then 18 – 6 and finally 12 . This is an incorrect result. If we do not use Rule 2 then the following illustrates how it can go wrong 4*5%2 Going from left to right we evaluate the x first, which reduces the expression to 20 % 2 which becomes 0 . If we evaluated the % first then the expression would reduce to 4 x 1 which becomes 4 . This is an incorrect result. Remember, we are using integer mathematics when doing our calculations, so we get integer results when doing division. For example ./calc 20 / 3 6 Also note that we can use the unary + and – operators. For example ./calc -5 / +2 -2 ./calc +2 - -2 4 Your program must also check to make sure the command line arguments are valid. If not your program must generate an appropriate error message and then terminate with non-zero exit status. You should also check for division by zero errors and numeric out-of-bounds errors. As part of your program design, it is expected you will create classes to model the problem domain. Program Hints 1. Getting your program to solve expressions that only use the + and – operators is fairly easy. I would suggest you get your program working at this level before attempting to get it to work with the other operators. 2. While this problem can be solved using iteration, it is easier to solve using recursion.
プロジェクト ID: 13742352

プロジェクトについて

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

お金を稼ぎたいですか?

Freelancerで入札する利点

予算と期間を設定してください
仕事で報酬を得る
提案をご説明ください
登録して仕事に入札するのは無料です
この仕事に6人のフリーランサーが、平均$123 USDで入札しています
ユーザーアバター
Hi, this project has quite a lot of requirements. So the bid reflect my requested price. Work will be done in Linux, so you can freely run on your MacOS. Thanks.
$333 USD 2日以内
0.0 (0 レビュー)
0.0
0.0
ユーザーアバター
Should be no problem, ask me any questions.
$35 USD 2日以内
0.0 (0 レビュー)
0.0
0.0

クライアントについて

AUSTRALIAのフラグ
Australia
0.0
0
メンバー登録日:4月 16, 2017

クライアント確認

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