Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

Programming Tasks 1.) Command Line Calculator a. Command Line Calculator for individual integer Numbers (simplecalc.qpp, simplecalc.exe) This is about creating a command line calculator. A first number followed by an operator followed by a second number is passed via command line as shown below UsersNorbertsinplecalc.exe 1 1 Depending on the operator, the numbers should be calculated accordingly. The operations addition, subtraction, multiplication, division, and modulo for integers are to be realized with the functions add (.), sub (...) mul ( ), diy(…), and mod ( ) , respectively. Here and below, the three dots in parentheses after a function name are intended to indicate that the function expects arguments. These functions accept a first argument and a second argument, both of type int, via call-by-value. They should also accept a third argument of type bool by means of call-by-reference. The functions should return the result of the calculation as an integer (type int). If in the function div(.) or in the function mod (..) the second number is zero, the bool variable should be set to false and the first number is to be returned as result in this case. In all other cases the bool variable must be set to true. Please implement a complete solution of the task. Parts of it are already given below Your program should work as shown below: UsersNorbert sinplecalc.exe 11 Users Norbert>sinplecalc.exe 1-1 Users Norbert>sinplecalc.exe 2-2 24 UsersNorbert sinplecalc.exe 278 annot divide by zero :NUsersNorbert)sinplecalc.exe 5 2 Please note that there need to be spaces between the entries on the command line for things to work well.
C+ Code Snippets //your code here (also abbreviated below as //yours) /Ifunction prototypes int add(// your code here): int sub(//your code here) int mul(//your code here) int div(// your code heze) int mod(//your code heze) int main (int argc, char argvD //your code here (short: //yours) // your code here // your code here //your code here // your code here cout << //yours << + << //yours <<--” << add (//yours) << endl; cout << //yours<-</yours < <<sub(// yours) <endl: cout << //yours<<*</yours < << mul(// yours) <<endl; /yoursdiv//yours) //your code here cout << //yours << << //youts <<-.- くく//yours << endl; //your code here cout <<cannot divide by zero<endl: //your code here /yours-mod //yours) //your code here cout <s //yours <1/yours//yours << endli //your code here cout << cannot calculate modulo with respect to 0<endl: //your code here return 0: Please test that your output is formatted properly by performing the following steps: 1. Run simplecalc.exe 1+ 2> myoutputla.txt on the command line. To this end, enter simplecalc.exe 1+2 myoutput1atxt on the command line without. Note myoutput1a.txt. This is a regular text file that can be opened, eg, using Notepad redirects program outputs to file, he 2. Run fc myoutputla.txt correct1a.txt on the command line. f is a file comparison program. To do t comparison, download correctlatr. If the contents of the two files are identical, then you will get a res similar to what is shown below. Users Norbertsinplecale.exe1 2 nyout putla.txt Users Norbert>fc nyoutputia.txt correctia.txt onparing files nyoutputla.txt and CORRECTIA.TXT C: no differences encountered Please note that there need to be spaces between the entries on the command line for things to work well
b. Command Line Calculator for Fields of integer Numbers (veccalc.cpp, veccak.exel Now write an extended version of simplecalc that allows the processing of fields represented as vectorcint> in Ct+. The basic procedure is the same as for simplecalc. Only now two fields with integers are passed. They have to be processed element by element as shown below, e.g, for :Viser Horbert)vec cale.exe 1 2 3 4 ◆ § 6 ? 8 Elenentwise Sun 7-18 48- 12 Analogous to simplecal, the operations addition, subtraction, multiplication, division, and modulo are to be implemented. Again, the functions should be called add (m), sub (-), mul (…), div (-), and mod (m), but this time they should operate on fields of type vectorcint>. Here and below, the three dots in parentheses after a function name are intended to indicate that the function expects arguments. If a zero is found in the second field during division or modulo calculation, a bool variable must be set to false. In this case, the corresponding number from the first field must be returned as the result of the operation. Since the solution of veccak is again a field, a corresponding output function is needed. Implement a suitable display() function. Follow the partially implemented function below. Please implement a complete solution of this task. Parts are already given in part. Your output should follow the following screen shot Elementuise Sun Elementuise Difference sersWerbert veccalexe765-4321 Elementuise Predact ivisen by zero eceured for at least one elenent Quot ient ed with respect to zere for at least one elenent Elenentuise Red Operat ion Please test that your output is formatted properly by performing the following steps 1. Run veccak.exe 5678 /2 304> myoutput1b.tt on the command line 2. Run fc myoutput 1b.txt correct1b.t on the command line as well after downloading the file correct1 b.txt If the two files are identical, you receive an output similar to what is shown below :VisersNorbert)vecca1c.exe S 6 7 / 2 3 @ 4 》 nyout put 1 b.txt NUsersNorbert>fc nyout put1b.txt cerrectlb.txt onparing files nyoutputib.txt and CORRECT1B.TXT C: ne differences encountered
C++ Code Snippets /your code here (also abbreviated below as: 1/ yours //function prototypes vectorくînt> add (//yours) ; vectorcint> sub(//yourS vectorcint> mul (//yourS) vectorcint> div(//yours) vectorcint> mod (//yours void display(/yours) int main (int argc, char argv) // your code here /Note: a, b c are of type vectorcint> //you need to figure out their length //the variable status is of type bool t//yours) ) else if (//yours) ) else if (//yours) ) else if (//yours) c-add (a,b,status): display(a, b, c) c-sub(a,b,status) display (a, b, c, -); c-mul (a,b,status) display (a, b, c ) div ( a,b,status); C if (status) display (a, b,c,) else f cout << divi son by zero occurred for at least one element.<end display (a,b,c.) ) else if (//yours) cmod (a,b,status); if (status) display la, b, c, else( cout << mod with respect to zero for at least one element. << endl: display(a,b.c,) else cout << Unknown operator! Returning to operating system...< end2 return (-1) return 0
void display//your code here) if (//yours) cout<< Ini: Elementwise Sum<< endl; for (/yours ) else if (//yours) cout<< Ini: Elementwise Difference <<endl; for (/yours ) else if //yours) cout<<ni: Elementwise Product << endi, for (/yours) ) else if (//yours) cout << ni: Elementwise Quotient <<endl for (//yours) ) else if (//yours) cout<< Ini: Elementwise Mod Operation<<endl: for //yours ) else cout<< unknown operator << endl; return
Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.