1. Homepage
  2. Programming
  3. COMP1038 Programming and Algorithms Coursework 1: Calculator

COMP1038 Programming and Algorithms Coursework 1: Calculator

Engage in a Conversation
Nottingham NingboCOMP1038Programming and AlgorithmsC

Programming and Algorithms Coursework 1 CourseNana.COM

Release 1.0 CourseNana.COM

Programming and Algorithms Teaching Team CourseNana.COM

Nov 02, 2023 CourseNana.COM

CONTENTS CourseNana.COM

0.1 Changelog .............................................. 1 CourseNana.COM

  1. 1  Coursework Specification 2 1.1 Introduction ............................................. 2 1.1.1 Keywords.......................................... 2 1.1.2 Definitions ......................................... 2 CourseNana.COM

    1. 1.2  Submission.............................................. 3 CourseNana.COM

    2. 1.3  Plagiarism .............................................. 3 CourseNana.COM

    3. 1.4  Marking ............................................... 4 CourseNana.COM

    4. 1.5  Question:calculator-‘Arithmeticcalculator’............................ 5 1.5.1 ProblemDescription .................................... 5 1.5.2 Input............................................. 5 1.5.3 Output............................................ 5 1.5.4 SampleInput/Output .................................... 5 1.5.5 SampleFilesandCommand-lineUsages.......................... 6 CourseNana.COM

  2. 2  Source Code Submission Manual 7 2.1 TechnicalNotes ........................................... 7 2.2 Possibleresults............................................ 7 2.3 JudgingProcess ........................................... 8 CourseNana.COM

    2.3.1 Submittingsolutions .................................... 8 2.3.2 Compilation......................................... 8 2.3.3 Testing ........................................... 8 2.3.4 Restrictions......................................... 8 CourseNana.COM

    2.4 Codeexamples............................................ 9 CourseNana.COM

Programming and Algorithms Coursework 1, Release 1.0 CourseNana.COM

0.1 Changelog CourseNana.COM

Warning: Thecontentofthisfilemaychangeinfuture,pleasealwaysrefertothelatestversiononMoodle. 2023-10-28 1.0 CourseNana.COM

Release candidate. CourseNana.COM

0.1. Changelog 1 CourseNana.COM

1.1 Introduction CourseNana.COM

This is the first marked coursework for Programming and Algorithms (COMP1038). It is worth 30% of the module mark. It requires you to write a program to solve the given problem(s). The deadline for this coursework is 23:55 on Wednesday 22nd of November 2023. CourseNana.COM

Read the entire document before beginning the coursework. CourseNana.COM

If you have any questions about this coursework, please ask in the Q&A forum on Moodle, after a lecture, in a lab, or during the advertised oce hours. Do not post your program or parts of your program to Moodle as you are not allowed to share your coursework programs with other students. If any questions require this coursework to be clarified then this document will be updated and everyone will be notified via Moodle. CourseNana.COM

1.1.1 Keywords CourseNana.COM

The keywords MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, REC- OMMENDED, MAY, and OPTIONAL in this guide are to be interpreted as follow: CourseNana.COM

MUSThis word, or the terms REQUIRED, SHOULD or SHALL, mean that the instruction is an absolute re- quirement of this guide. CourseNana.COM

MUST NOT
This phrase, or the phrases SHOULD NOT or SHALL NOT, mean that the instruction is an absolute prohibition of this guide. CourseNana.COM

MAY This word, or the phrases RECOMMENDED or OPTIONAL, mean that the instruction is truly optional. 1.1.2 Definitions CourseNana.COM

standard input

This term, or the term stdin, mean that the stream from which input to the program is taken. Typically this is the keyboard, but it can be specified that input is to come from a serial port or a disk file, for example. CourseNana.COM

standard output

This term, or the term stdout, mean that the stream to which output from the program is sent. Typically this is a display, but it can be redirected to a serial port or a file. CourseNana.COM

standard error

This term, or the term stderr, mean that the stream to which error output from the program is sent. Typically this is a display, but it can be redirected to a serial port or a file. CourseNana.COM

<empty line> CourseNana.COM

This term, or the terms \n, \r\n, <LF> or <CR><LF>, mean the character \n after the last non-whitespace character in the previous content. CourseNana.COM

CHAPTER ONE CourseNana.COM

COURSEWORK SPECIFICATION CourseNana.COM

For example, the following representations are all equivalent: CourseNana.COM

Programming and Algorithms Coursework 1, Release 1.0 CourseNana.COM

<empty line> \n CourseNana.COM

first first\nsecond\nthird\nlast\n second
third
last
CourseNana.COM

<empty line> CourseNana.COM

1.2 Submission CourseNana.COM

You must submit a single C source code file containing all your code for this exercise. This file must be called calculator.c and must not require any other files outside of the standard C headers which are always available. The first line of the file should be a comment which contains your student ID number, username, and full name, of the form: CourseNana.COM

// 6512345 zy12345 Joe Blogs

The file must compile without warnings or errors using the command CourseNana.COM

gcc -std=c99 -lm -Wall calculator.c -o calculator

This command will be run on our Linux server CSLinux. If it does not compile, for any reason, then you will lose all the marks for testing (common reasons in the past have been submitting a file with the wrong filename, or developing your solution on your personal computer without having tested it on our Linux server). If the file compiles but has warnings then you will lose some marks for not correcting the warnings. CourseNana.COM

The completed source code file should be uploaded to the Coursework 1 Submission link on the COMP1038 Moodle page. You may submit as many times as you wish and the last submission will be used for marking. However, if you submit after the deadline, your last submission time will be considered for the late submission penalty. After the deadline has passed, if you have already submitted your exercise then you will not be able to submit again. If you have not already submitted then you will be allowed to submit once. CourseNana.COM

Late submissions: COMP1038 late submission policy is dierent from the standard university policy. Late sub- missions will lose 2 percentage points per hour, rounded up to the next whole hour. This is to better represent the large benefit a small amount of extra time can give at the end of a programming exercise. No late submissions will be accepted more than 50 hours after the exercise deadline. If you have extenuating circumstances you should file them before the deadline. CourseNana.COM

1.3 Plagiarism CourseNana.COM

You should complete this coursework on your own. Anyone suspected of plagiarism will be investigated and punished in accordance with the university policy on plagiarism (see your student handbook and the University Quality Manual). This may include a mark of zero for this coursework. CourseNana.COM

You should write the source code required for this assignment yourself. If you use code from other sources (books, web pages, etc), you should use comments to acknowledge this (and marks will be heavily adjusted down accord- ingly). The only exception to this is the dynamic data-structures (linked lists and others) developed during the lectures and tutorials; you may use these, with or without modification, without penalty as long as you add a com- ment in your program saying you have taken them from the lectures or tutorials and saying how you have modified it (or not modified it). If you do not acknowledge their source in a comment then it will be regarded as potential plagiarism. CourseNana.COM

1.2. Submission 3 CourseNana.COM

Programming and Algorithms Coursework 1, Release 1.0 CourseNana.COM

You must not copy or share source code with other students. You must not work together on your solution. You can informally talk about higher-level ideas but not to a level of detail that would allow you all to create the same source code. CourseNana.COM

Remember, it is quite easy for experienced lecturers to spot plagiarism in source code. We also have automated tools that can help us identify shared code, even with modifications designed to hide copying. If you are having problems you should ask questions rather then plagiarize. If you are not able to complete the exercise then you should still submit your incomplete program as that will still get you some of the marks for the parts you have done (but make sure your incomplete solution compiles and partially runs!). CourseNana.COM

1.4 Marking CourseNana.COM

The marking scheme will be as follows: CourseNana.COM

Tests (26 marks): Your program should correctly implement the task requirements. A number of tests will be run against your program with dierent input data designed to test if this is the case for each individual requirement. The tests themselves are secret but general examples of the tests might be: CourseNana.COM

Does the program work with the example I/O in the question? Does the program work with typical valid input?
Does the program correctly deal with invalid input?
Does the program output match the required format? CourseNana.COM

Does your code run correctly without any run-time error? CourseNana.COM

As noted in the submission section, if your program does not compile then you will lose all testing marks. As well as if you submit a dierent type of file apart from a single C source code file containing all your code for this exercise and the file name is dierent from calculator.c then you will also lose all testing marks. We usually use an automatic marking system to test/mark your coursework submissions. So you should strictly follow the output format specified in this task description while implementing your program. Otherwise, your program will fail to test and you will lose marks. If your code compiles with warnings, each warning message causes 10% mark deduction. CourseNana.COM

  • Appropriate use of language features (2 marks): Your program should use the appropriate C language features in your solution. You can use any language features or techniques that you have seen in the course, or you have learned on your own, as long as they are appropriate to your solution. Examples of this might be: CourseNana.COM

    • –  Have you broken your program down into separate functions? CourseNana.COM

    • –  Are all your function arguments being used? CourseNana.COM

    • –  If your functions return values, are they being used? CourseNana.COM

    • –  Are you using loops to avoid repeating many lines of code? CourseNana.COM

    • –  Are your if/switch statements making a dierence, or is the conditions always true or false making the statement pointless? CourseNana.COM

  • Source code formatting (2 marks): Your program should be correctly formatted and easy to understand by a competent C programmer. This includes, but is not limited to, indentation, bracketing, variable/function naming, and use of comments. CourseNana.COM

1.4. Marking 4 CourseNana.COM

Programming and Algorithms Coursework 1, Release 1.0 CourseNana.COM

1.5 Question: calculator - ‘Arithmetic calculator’ 1.5.1 Problem Description CourseNana.COM

Your task is to implement an arithmetic calculator program in C programming language.
The program takes one mathematical expression in a line, then output the result to the expression, otherwise output
CourseNana.COM

Invalid input and finish.
Your program should be able to handle arithmetic operators
+, -, *, /, % (modulo), and (, ). CourseNana.COM

1.5.2 Input CourseNana.COM

The input is one mathematical expression in a line of no more than 100 characters. A valid numerical value satisfies the following conditions: CourseNana.COM

Its length must be no more than 12 digits including the decimal point.
Itisinoneoftheforms123,-12.3,12.3000,123.and.123,butNOTintheforms1e23,00123,+12.3 CourseNana.COM

and 00.123. CourseNana.COM

A valid arithmetic expression contains arithmetic operators, numerical values, and white-spaces. It may contain extra spaces in between an operator and a value and you should simply ignore them. Your program should output Invalid input if the input contains more than 100 chars. You MUST NOT assume the expression is always legal and SHOULD validate the expression yourself. CourseNana.COM

Some examples of valid arithmetic expression are: CourseNana.COM

(1 + 2)* 3.14
-10.567854446/ 15.34
0.5* ((1.5 -1)+   2)

1.5.3 Output CourseNana.COM

Output the result to the input expression.
The answer should have an absolute or relative error of at most
106, if the expression is invalid or cannot be CourseNana.COM

calculated, output case-sensitive string Invalid input. 1.5.4 Sample Input/Output CourseNana.COM

Input output CourseNana.COM

1+a Invalid input CourseNana.COM

Input output CourseNana.COM

(1+2+3)) Invalid input CourseNana.COM

1.5. Question: calculator - ‘Arithmetic calculator’ 5 CourseNana.COM

Programming and Algorithms Coursework 1, Release 1.0 CourseNana.COM

Input output CourseNana.COM

3.14%2 -1 Invalid input CourseNana.COM

Input output CourseNana.COM

3.141592685746* 2 Invalid input CourseNana.COM

Input output CourseNana.COM

1+2 * 3 7.000000 CourseNana.COM

1.5.5 Sample Files and Command-line Usages CourseNana.COM

To compile the C code: CourseNana.COM

gcc -std=c99 -lm -Wall calculator.c -o calculator To test the program with the sample files: CourseNana.COM

./calculator < 1.in
Then check the output is exactly the same as the content in the corresponding .out files. CourseNana.COM

To detect memory leak: CourseNana.COM

     valgrind --leak-check=full ./calculator < 1.in

Note: CourseNana.COM

< is used for redirect the input from your keyboard to a given file. CourseNana.COM

1.in is a file containing the input mathematical expression in the same folder with the program, and it may be replaced by other file names in testing and marking. You can replace it with other .in files such as 2.in as long as it exists. CourseNana.COM

1.5. Question: calculator - ‘Arithmetic calculator’ 6 CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Nottingham Ningbo代写,COMP1038代写,Programming and Algorithms代写,C代写,Nottingham Ningbo代编,COMP1038代编,Programming and Algorithms代编,C代编,Nottingham Ningbo代考,COMP1038代考,Programming and Algorithms代考,C代考,Nottingham Ningbohelp,COMP1038help,Programming and Algorithmshelp,Chelp,Nottingham Ningbo作业代写,COMP1038作业代写,Programming and Algorithms作业代写,C作业代写,Nottingham Ningbo编程代写,COMP1038编程代写,Programming and Algorithms编程代写,C编程代写,Nottingham Ningboprogramming help,COMP1038programming help,Programming and Algorithmsprogramming help,Cprogramming help,Nottingham Ningboassignment help,COMP1038assignment help,Programming and Algorithmsassignment help,Cassignment help,Nottingham Ningbosolution,COMP1038solution,Programming and Algorithmssolution,Csolution,