Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C0.2-1403 'inter 2023. hwsignumnl d1 DicieC IIvi: aspl by slap, lacest ta1 *lat welati. is dist Assignment 1 (Due Date Feb 16, 2023) OB.JECTIVE: Through

image text in transcribed

image text in transcribed
image text in transcribed
image text in transcribed
C0.2-1403 'inter 2023. hwsignumnl d1 DicieC IIvi: aspl by slap, lacest ta1 *lat welati. is dist Assignment 1 (Due Date Feb 16, 2023) OB.JECTIVE: Through three assignments, we will learn how to apply the concepts leamed in this course to develop a simple command-line calculator using programming language C. In the first assignment, we are going to kick off the initial step of developing the calculator. How? Yes, first write informal pseudocode for this program and then convert it to a flowchart. You should also prepare the skeleton of the C program that includes some initial tasks along with the simplest operations. Then in the following assignments, you will gradually complete the program step by step, based on what we learn in class. Part A: Brief introduction to the Command-line Calculator: The goal is to design and develop a simple command-line calculator. In this calculator, the user should be able to do simple mathematical operations, such as addition, subtraction, multiplication and division for various numbers. After running the program, first a list of five possible options is shown to the user. Then, the user must select one option from the list. A next set of messages will be shown to the user based on the selected option (in this first assignment, we assume that just options B and E are functional and if a user selects other options, an error message will be shown). In case the user selects option E, the program will show a goodbye message and terminate. If option B is selected, the user must enter the first number, then enter an operator (operators included in the prompt), and finally enter the second number. The program will then show the result of that calculation and prompt again to receive the selected option from the user. To give you a clear idea about the expectation, a sample output of the program is shown for this assignment. Those parts which are bold-italic are the user inputs during the execution. Welcome to my Command-line Calculator (Cto) Devetoper: Your fame wi1. ecute here Werpiont 1 . Dater Development date aill eone here Belect one of the following iters: B) - Binary Mathenatical Operationt. such at addition and subtroction. 0) - Whary Mathematical Operations, doeh as aquare root, and Iog. A) - hdvances Mathenatical Operationa, ianing varlablea, arraya. v) - Define variables and astign thean valuen. B) - Exit B Please enter the first futiter: 12 Please enter the operation (+,+,+,f)= + Please intet the aecond numbet? 3 The tesult is 15 Pleast seltet, your aption (E,U,A,V,I,1 47 Sorry, at this time I don"t bave enough knowledfe to serve you fin thid cateqoty. Pleasa aelect your option (B,B,A,V,E ) A Borky, at this tine I don't haye angugh knowledge to serye you in. this categoty. Please tlelect yoar option ( 11,0,A=V+E ) P Sorry, at this tine" thon't have enedgh knouledge to therye you in this eategoty. 1 Pleane rolect your option (B, U, B,V,E) 8) Please encer che first number: 18 Dlease encer the opezatios (+,,,1)= please enter the secand number: 3 The result is 54 Pleagh select your option (It,t,A,V,E ) B Please enter the first mimbert Please encer the operation I+,,+,/1= Pleake enter the second number 13 The result 154 Pleane delect your option (B,U,A,V,E. E. Thank: for using my simple Calculator. Hope to eee you soon again, Coodeyel As mentioned before, in this first version of the calculator, you just need to cover the four mathematical operations, addition, subtraction, multiplication, and division. Also, for all calculations, the user can only perform the operation for two operands, like the example above. Part B: Pseudocode: (40 marks) Using the above explanation and sample outputs of the program execution, write the pscudocode for the Coamand-line Calculator program. As a hint, some lines have been written, and you should complete the rest. 1. Start 2. Show a Welcome message to the user 3. Loop \{ for asking the user to input their option\} a) Show a prompt for user selection 4. End of loop 5. Show a Goodbye message 6. End Part C: Flewchart (40 marks) Using the pseudocode you wrote in the previous part, draw a flowehart for it. You can use any flowchart software, like Raptor, Flogorithm, draw.io, or draw it on any software with graphical capabilities, like Dia (available on the School UNIX server), Word, PowerPoint, or Paintbrush. Part D: C program (20 marks) Based on the flowehart and pseudocode you've designed on the previous steps, now you are going to provide the skeleton of the C program for the calculator (meaning all core functionality will be comments aside from the skeleton of the program). Your task in this part is to start writing a C program with the following parts: - Include required standard libraries - Create the main function - Using C commands display welcome messages to the user - Display the list of options and show a message to the user to select an option. - For the other parts, write COMMENTS for each step of the code based on your pseudocode. Like in any programming language, in C programs you can add comments at any part of your code. Comments are not executable but will help the reader to understand the code. The functionality of these parts are not required for the first assignment, we only need comments. Hint: There are two ways to write comments inside a C program: 1. In-line comment: type // and then write the comment. The rest of the line after // will be considered as comments and not the actual program code Example: 2. Multi-line comment: type / / and start writing your comment in one or more lines. In the end, finish the comments by typing */ Example: 1. This progtam implementa a mimple command-1ine caleulator, in which a user can... Save the file in the format of a C source file as clc.e in your working directory, i.e., /home/yourUserName/Winter/comp1400 (or other base directories). As you are already in the working directory as completing UNIX Exercise, you can now compile the C program with the following command to produce an executable. gec W all clc.e 0 clc.out You can run the executable file with the following command. Jclc.out Submission Instruction: You have to submit your solutions as A SINGLE ZIP FILE into Brightspace before the deadline. The zip file name is your student id (for instance, if your student id is 1234567, the zip file name would be 1234567. zip) that includes one or two pdf files for non-programming questions, and ene c file (a text file with extension c) for the e program. PLEASE DO NOT submit any other types of files, such as compiled files (ex. clc.out), files associated with specific software, etc. Therefore, for assignment one, your zip file should contain the following files: - One pdf or text (.txt) file for the pseudocode (part B) - One pdf, or screenshot (.png or .jpg) file for the flowchart (Par C) (Answer to this part can be inside the first pdf file as well). If you create your flowchart in Raptor, please also include the rap file. - One C file, named "elc.e", which should be a simple text file, containing your c program (Part D). Please check the extension and make sure it is a C file format (.c). Submission of other file types will make problems for grading your assignments, and you will lose a partial or complete marks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

What qualities do you see as necessary for your line of work?

Answered: 1 week ago