Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please explain thoroughly Assignment #1 (Due Date Feb 16, 2023) OBJECTIVE: Through three assignments, we will learn how to apply the concepts learned in this

Please explain thoroughly

image text in transcribedimage text in transcribedimage text in transcribed

Assignment \#1 (Due Date Feb 16, 2023) OBJECTIVE: Through three assignments, we will learn how to apply the concepts learned 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 (CLC) Developer: Your name will come here Version: 1 Date: Development date will come here Select one of the following items: B) - Binary Mathematical Operations, such as addition and subtraction. U) - Unary Mathematical Operations, such as square root, arta log. A) - Advances Mathematical Operations, using variables, arrays. V) - Define variables and assign them values. E) - Exit B Please enter the first number: 12 Please enter the operation (+,,,+)= Please enter the second number: 3 The result is 15 Please select your option {B,U,A,V,E Ef Sorry, at this time I don't have enough knowledge to serve you in this category. Please select your option (B,D,A,V,E) A Sorry, at this time I don't have enough kndwledge to serve you in this category. Please select your option (B,B,A,V,E, V Sorry, at this time I don't have enough knowledge to serve you in this eategory - 1 Please select your option (B, U, A, V, E) B Please enter the first number: 18 Please enter the operation (+,,+,/) : Please enter the second nurtber: 3 The result is 54 Please select your option ( B,U,A,V,E) B Please enter the first number: 9 Please enter the operation (+,,+,/) : Please enter the second number: 13 The result is 4 Please select your option ( B,D,A,V,E ) E Thanks for using my Simple Calculator. Hope to see you soon again, Goodbye! 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 pseudocode for the Command-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: Flowchart (40 marks) Using the pseudocode you wrote in the previous part, draw a flowchart 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 flowchart 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: / This program implements a simple command-line calculator, in which a user can... /... Save the file in the format of a C source file as clc.c 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.c 0 clc.out You can run the executable file with the following command. /clc.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 one c file (a text file with extension c) for the c 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 (Part 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 "clc.c", 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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

Can you tell me about the company culture?

Answered: 1 week ago

Question

Additional Factors Affecting Group Communication?

Answered: 1 week ago