MasterACE14 Posted December 18, 2011 Share Posted December 18, 2011 Good Day everyone, I just got my results back for my C++ assignment at uni and am not happy with the results. I've lost marks for being too accurate with my calculations and for small things like 'not enough commenting' (for variables that are self explanatory). I would like to share my results, the assignment sheet and my answers to the assignment questions as well as my program source. I have asked my lecturer and there is no assignment marking guideline for students to view, which frustrates me even more. Assignment Sheet Programming Fundamentals 700008 Assignment 1 (10%) Date Due: 12pm, 02/12/2011 (Week 6) NOTE: This is an individual assignment. It is each student’s responsibility to be aware of and adhere to the policies regarding academic misconduct. You will be asked to modify the code and the algorithm in the week 7 tutorial class. Failure to satisfactorily demonstrate understanding of your algorithm and the program could result in a failing mark for parts 2 & 3. Learning Objectives: 1. Describe and explain the purposes and operations of the basic components of a computer and a computer system 2. Discuss and explain the concepts of data and procedural representation, programming languages, compilers, interpreters and development environments 3. from a simple problem description, identify desired inputs, outputs, and the necessary processing operations to convert input into output 4. design program logic using both graphical and pseudo code techniques that employ standard control structures of sequence, iteration and selection 5. translate design structures into code in a high-level procedural language, verify the code, and devise and implement test plans to minimise occurrence of errors Assignment Submission Guidelines You have to submit the following documents on vUWS before the due date. 1. Answers to Part 1 and Part 2 in MS Word (You have to include your name and Student ID on the document.) 2. C++ Code (In the C++ code your name and Student ID should be part of a comment at the top of the program.) Part 1 (20 marks) 1.1 Explain the five major hardware components of a computer system. (10 marks) 1.2 Describe a) what a compiler does with a program’s source code. b) what a linker does with a compiled code. Part 2: Design you program (40 marks) The Fast Freight Shipping Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 miles Shipped 2 kg or less $1.10 Over 2 kg but not more than 6 kg $2.20 Over 6 kg but not more than 10 kg $3.70 Over 10 kg but not more than 20 kg $4.80 Design a program that asks for the weight of the package, the distance it is to be shipped, and displays the charges. Input Validation: Do not accept values of 0 or less for the weight of the package. Do not accept a weight of more than 20kg (this is the maximum weight the company will ship). Do not accept distance of less than 10 miles or more than 3000 miles. These are the company minimum and maximum shipping distances. The design should include the following details. 1. IPO chart (5 marks) 2. Pseudo-code (25 marks) 3. 5 sets of test data (Test cases should be derived based on different scenarios) (7.5 marks) 4. Expected output for each test data set (2.5 marks) Part 3: Code (40 marks) Write the program according to your design. 1. The program should have comments and use good programming practices, such indentation blank lines, etc. (10 marks) 2. The program should handle the logic given in the problem description (30 marks) Assignment 1 Answers Assignment 1 Part 1) 1.1) 1 - Central Processing Unit (CPU): Performs the instructions of a computer program. 2 - Main Memory (volatile): Directly accessible by the CPU to store and read instructions. 3 - Secondary Memory/Storage (non-volatile): Not directly accessible by the CPU for storage. 4 - Input Devices: A device which can provide data to a computer. 5 - Output Devices: A device that can communicate data from the computer to the outside world. 1.2) a) A compiler converts the source code of a programming language into a computer language. b) The creation of a single executable file from many different object files. Part 2) 1) IPO Chart Input Process Output PackageWeight td]Calculate_Charge() Charge ShippingDistance [/td] 2) Pseudocode Calculate_Charge Set PackageWeight to zero Set ShippingDistance to zero Set Charge to zero Get PackageWeight Get ShippingDistance IF PackageWeight <= 0 OR PackageWeight > 20 THEN Display "Package Weight must be greater than 0 and 20 or less" ELSE IF ShippingDistance < 10 OR ShippingDistance > 3000 THEN Display "Shipping Distance must be 10 or greater and 3000 or less" ELSE IF PackageWeight <= 2 THEN Charge = (ShippingDistance / 500) * 1.10 ELSEIF PackageWeight > 2 AND PackageWeight <= 6 THEN Charge = (ShippingDistance / 500) * 2.20 ELSEIF PackageWeight > 6 AND PackageWeight <= 10 THEN Charge = (ShippingDistance / 500) * 3.70 ELSEIF PackageWeight > 10 AND PackageWeight <= 20 THEN Charge = (ShippingDistance / 500) * 4.80 ENDIF Display "Total Charge is: $" Charge ENDIF ENDIF END 3) Test Data Input Data Data Set 1 Data Set 2 Data Set 3 Data Set 4 Data Set 5 PackageWeight 2 7 4.5 5 1 ShippingDistance 550 2000 22 50 1760 4) Expected Output Expected Results Data Set 1 Data Set 2 Data Set 3 Data Set 4 Data Set 5 Charge 1.21 14.80 0.10 0.22 3.87 Source Code #include <iostream> #include <iomanip> using namespace std; int main() { float PackageWeight = 0, ShippingDistance = 0, Charge = 0, Distance = 0; cout << "Fast Freight Shipping Company :: Total Charge Calculator\n"; cout << "--------------------------------------------------------\n\n"; // prompt user for Package Weight cout << "Enter your Package Weight: "; cin >> PackageWeight; // assign the Package Weight to a variable cout << "\n"; // check the Package Weight meets our requirements, otherwise display an error message if(PackageWeight <= 0 || PackageWeight > 20) cout << "Package Weight must be greater than 0 as well as 20 or less.\n"; else { // prompt user for Shipping Distance cout << "Enter your Shipping Distance: "; cin >> ShippingDistance; // assign the Shipping Distance to a variable cout << "\n"; // check the Shipping Distance meets our requirements, otherwise display an error message if(ShippingDistance < 10 || ShippingDistance > 3000) cout << "Shipping Distance must be 10 or greater as well as 3000 or less.\n"; else { /* if no error messages have been displayed this far, perform the appropriate calculation for the Charge */ Distance = (ShippingDistance / 500); if(PackageWeight <= 2) Charge = Distance * 1.10; else if(PackageWeight > 2 && PackageWeight <= 6) Charge = Distance * 2.20; else if(PackageWeight > 6 && PackageWeight <= 10) Charge = Distance * 3.70; else if(PackageWeight > 10 && PackageWeight <= 20) Charge = Distance * 4.80; cout << setprecision(2) << fixed; cout << "Total Charge is: $" << Charge << endl; } } system("pause"); return 0; } Marks Programming Fundamentals 70008 Marking Table Student Id: … ******** Name: Nathan Poultney Question Comments Mark 1.1 (10 marks) Should explain more. 7 1.2 a (5 marks) Should explain more. 3 1.2 b (5 marks) Should say that linker link the library files to the object files. 4 2.1 (5 marks) Error output missing 4 2.2 (25 marks) You got the logic for calculating rates wrong! 21 2.3 (7.5 marks) One set of invalid inputs expected. 7 2.4 (2.5 marks) [td]2.5 3.1 (10 marks) Need to comment variables. 9 3.2 (30 marks) You got the logic for calculating rates wrong! 26 Total Mark 83.5 Assignment in class Test Pass Late penalty 0 Final Mark & Grade 83.5 Am I being too pedantic or have I been ripped off? I appreciate your thoughts. Thanks, Ace Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/ Share on other sites More sharing options...
Philip Posted December 19, 2011 Share Posted December 19, 2011 I can see some of the marks being taken off for part 1, but for the code (especially the commenting) I think it is BS. However, I've also learned the hard way, that in a university you cater to the professor's opinions & preferences, rather than best practices. I learned real quick that if they want a comment for everything, I'd comment everything beyond what I thought was necessary. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299097 Share on other sites More sharing options...
MasterACE14 Posted December 19, 2011 Author Share Posted December 19, 2011 I can see some of the marks being taken off for part 1, but for the code (especially the commenting) I think it is BS. I think the deducted marks there are reasonable, I should of explained in more detail. The lost mark for commenting was allegedly because I didn't comment above the variables what the variables are for, arguing that the names I gave the variables should say it all apparently isn't enough :/ I'd comment everything beyond what I thought was necessary. yeah I shall be doing that for assignment 2. Thanks for your opinion, appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299139 Share on other sites More sharing options...
Philip Posted December 19, 2011 Share Posted December 19, 2011 The lost mark for commenting was allegedly because I didn't comment above the variables what the variables are for, arguing that the names I gave the variables should say it all apparently isn't enough :/ Yeah... I completely agree that they didn't need to be commented. Le sigh Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299163 Share on other sites More sharing options...
scootstah Posted December 19, 2011 Share Posted December 19, 2011 The lost mark for commenting was allegedly because I didn't comment above the variables what the variables are for, arguing that the names I gave the variables should say it all apparently isn't enough :/ While it may be obvious in this case what the variables are for, and commenting may not be needed...that won't always be the case. There will be times you have seemingly obscure variables and without commenting, people won't know what the hell is going on. I believe the point here is to teach you that people won't always see things as obviously as you do, being the one that wrote it. It's easy to, in this case, say "oh well it's obvious that PackageWeight is for a package's weight", but later on down the road you might say "well, it's obvious that PW means the package's weight" - even though it make sense if you just stared at it for 6 hours, but someone who just looks at it won't immediately know what it means. I guess you could say "well just use good variable naming" and this is true, but sometimes it just happens. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299183 Share on other sites More sharing options...
MasterACE14 Posted December 19, 2011 Author Share Posted December 19, 2011 I believe the point here is to teach you that people won't always see things as obviously as you do, being the one that wrote it. It's easy to, in this case, say "oh well it's obvious that PackageWeight is for a package's weight", but later on down the road you might say "well, it's obvious that PW means the package's weight" - even though it make sense if you just stared at it for 6 hours, but someone who just looks at it won't immediately know what it means. I guess you could say "well just use good variable naming" and this is true, but sometimes it just happens. yeah that's true, although I would of preferred that have been in the feedback rather than resulting in a deducted mark. Fair point, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299199 Share on other sites More sharing options...
scootstah Posted December 19, 2011 Share Posted December 19, 2011 Indeed. If this was the first assignment in the class, then I should think he would at least give you some coding guidelines to go by. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299207 Share on other sites More sharing options...
MasterACE14 Posted December 19, 2011 Author Share Posted December 19, 2011 It was the first assignment, and there was no guidelines of any sort unfortunately :-\ Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299259 Share on other sites More sharing options...
.josh Posted December 19, 2011 Share Posted December 19, 2011 IMO the "guideline" is the marks/comments so that you will improve next time around. Remember, school is a learning process, where you go from suck to not suck. It's not intended to be perfection every round. Also, it is a good thing to an extent to defend your work, but in the real world...you're always going to have a boss who tells you one thing and means another, and "That's not what you said" only goes so far. So, you should take this as a lesson to take it upon yourself to ask questions and get clarification on everything beforehand. Remember, the reason you (will) have the job is because you know the details, not the boss - they don't know any better, so it is up to you to pry that shit out of them. But anyways, yeah I agree as far as commenting. Always err on the side of over-commenting. If it's your own code that only you will ever touch, and you're confident in yourself that your naming conventions are enough for you, that's fine. But in the real world where you're working with lots of other peoples' code and they yours, there's really no such thing as too many comments. Also want to mention that when you comment, you need to comment what your intentions are, what you are expecting to happen. The code reflects the comments, not the other way around. IOW the comments are there to explain in human language what the script is supposed to be doing. For me, my pseudo-code usually turns into my comments. But also, comments are especially important if you're trying to track down a logic bug. The first and most important step to tracking down bugs is to figure out what it's supposed to be doing in the first place, so if you have clearly written comments then you can compare them to the actual code and more easily find those bugs. "Oh hey, it says here that I'm supposed to be doing xyz but the code clearly doesn't do that!" sort of thing. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299376 Share on other sites More sharing options...
KevinM1 Posted December 19, 2011 Share Posted December 19, 2011 RE: commenting, you should write doc blocks before the definition of each function, including main. Write it along the lines of PHPDoc (http://www.phpdoc.org/), or whatever C++ devs usually use. That will take care of about 90% of it right there. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299383 Share on other sites More sharing options...
MasterACE14 Posted December 19, 2011 Author Share Posted December 19, 2011 IMO the "guideline" is the marks/comments so that you will improve next time around. Remember, school is a learning process, where you go from suck to not suck. It's not intended to be perfection every round. Also, it is a good thing to an extent to defend your work, but in the real world...you're always going to have a boss who tells you one thing and means another, and "That's not what you said" only goes so far. So, you should take this as a lesson to take it upon yourself to ask questions and get clarification on everything beforehand. Remember, the reason you (will) have the job is because you know the details, not the boss - they don't know any better, so it is up to you to pry that shit out of them. true, I didn't think about it like that. But anyways, yeah I agree as far as commenting. Always err on the side of over-commenting. If it's your own code that only you will ever touch, and you're confident in yourself that your naming conventions are enough for you, that's fine. But in the real world where you're working with lots of other peoples' code and they yours, there's really no such thing as too many comments. Also want to mention that when you comment, you need to comment what your intentions are, what you are expecting to happen. The code reflects the comments, not the other way around. IOW the comments are there to explain in human language what the script is supposed to be doing. For me, my pseudo-code usually turns into my comments. But also, comments are especially important if you're trying to track down a logic bug. The first and most important step to tracking down bugs is to figure out what it's supposed to be doing in the first place, so if you have clearly written comments then you can compare them to the actual code and more easily find those bugs. "Oh hey, it says here that I'm supposed to be doing xyz but the code clearly doesn't do that!" sort of thing. I think I shall have to be more precise with my commenting from now on. Pseudo-code into comments is a good idea, haven't thought of that one. On reflection the variable 'Distance' in my code could of used commenting, I guess looking at it from someone else's perspective really shows how unclear it really is. RE: commenting, you should write doc blocks before the definition of each function, including main. Write it along the lines of PHPDoc (http://www.phpdoc.org/), or whatever C++ devs usually use. That will take care of about 90% of it right there. ah yes, completely forgot about that. I shall do this from now on! Thanks for the feedback guys! Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299544 Share on other sites More sharing options...
kicken Posted December 20, 2011 Share Posted December 20, 2011 3.1 (10 marks) Need to comment variables. 9 I could agree with a mark off for commenting due to this line: float PackageWeight = 0, ShippingDistance = 0, Charge = 0, Distance = 0; You have two different variables related to distance, but the problem description only includes one distance (what the user entered for their shipping distance). It's not obvious what the other distance variable is for until you read the code later on. There's other way to make it more obvious without necessarily having to comment on the variables, but I could agree with a mark off in general for lack of clarity. 3.2 (30 marks) You got the logic for calculating rates wrong! 26 I could see how that mark could be the case as well. Your code calculates the rate using a fraction which means it will essentially be prorated. It doesn't specifically say in the problem whether this is desired or not, but typically things are not prorated in my experience. This is a point where you could have asked for a clarification. Example: I'm shipping a package weighing 5kg a distance of 100 miles. By your calculation, we have a total cost of: $0.44. (2.20 * (100/500)) Instead of a fractional distance, lets treat it as blocks. 0-500, 500-1000, 1000-1500, ... By doing that, we end up with a shipping cost of $2.20: (2.20 * (ceil(100/500)). Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299586 Share on other sites More sharing options...
MasterACE14 Posted December 20, 2011 Author Share Posted December 20, 2011 3.1 (10 marks) Need to comment variables. 9 I could agree with a mark off for commenting due to this line: float PackageWeight = 0, ShippingDistance = 0, Charge = 0, Distance = 0; You have two different variables related to distance, but the problem description only includes one distance (what the user entered for their shipping distance). It's not obvious what the other distance variable is for until you read the code later on. There's other way to make it more obvious without necessarily having to comment on the variables, but I could agree with a mark off in general for lack of clarity. Yeah fair call. Instead of a fractional distance, lets treat it as blocks. 0-500, 500-1000, 1000-1500, ... By doing that, we end up with a shipping cost of $2.20: (2.20 * (ceil(100/500)). This is how we were apparently suppose to do it, however I don't believe this is an error on my part as I did what the question said. If it was intended to be done a certain way you'd think the question would say so, possibly providing an example input/output. Cheers for your input, appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299589 Share on other sites More sharing options...
kicken Posted December 20, 2011 Share Posted December 20, 2011 This is how we were apparently suppose to do it, however I don't believe this is an error on my part as I did what the question said. If it was intended to be done a certain way you'd think the question would say so, possibly providing an example input/output. Cheers for your input, appreciated. That's one of the things you have to watch out for as a developer. There have been numerous times where I have been tasked with something that the requester though was simple, then I ask them all kinds of questions regarding things they 'didn't think about' and soon they realize it wasn't so simple after all. There's been a few times as well where I will do just like you did and develop it in a certain way just to have it rejected and need redone because that's not what they ment. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299596 Share on other sites More sharing options...
MasterACE14 Posted December 20, 2011 Author Share Posted December 20, 2011 This is how we were apparently suppose to do it, however I don't believe this is an error on my part as I did what the question said. If it was intended to be done a certain way you'd think the question would say so, possibly providing an example input/output. Cheers for your input, appreciated. That's one of the things you have to watch out for as a developer. There have been numerous times where I have been tasked with something that the requester though was simple, then I ask them all kinds of questions regarding things they 'didn't think about' and soon they realize it wasn't so simple after all. There's been a few times as well where I will do just like you did and develop it in a certain way just to have it rejected and need redone because that's not what they ment. yeah very true, that would be an absolute pain, especially if you have to start over. Good point. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299597 Share on other sites More sharing options...
premiso Posted December 20, 2011 Share Posted December 20, 2011 I would agree with Josh on most points. But the commenting part on variables etc. I do have issues with, but as he stated that in the real world, you do what your boss tells you, and if you never got the clarification from him, that is your mistake, never the bosses. As far as how I comment, I tend to lapse in the middle of code and more or less do the comments the PHPDoc style. Having a clear path of what the function should do, and where it should go is a great way to start it. From my professors in College, they always told me that you should not have to comment "common sense" code, but more or less tricky code. I got marked down for over commenting, and after they clarified that, I never got mark downs for that again. So if you take another Programming class, ask that question the first day, "What are your coding guidelines?" and ask if you can have a print out of their guidelines. In that way you will be covered for something like this as long as you follow it. If they say they do not have any, ask for that in writing too, the best way not to get screwed over is having it in writing one way or the other. I would get that from him, if possible, and bring up the argument that "if there is no clear route for me to follow, how can I follow it?" argument. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299612 Share on other sites More sharing options...
MasterACE14 Posted December 20, 2011 Author Share Posted December 20, 2011 From my professors in College, they always told me that you should not have to comment "common sense" code, but more or less tricky code. I got marked down for over commenting, and after they clarified that, I never got mark downs for that again. I shall keep in this mind. So if you take another Programming class, ask that question the first day, "What are your coding guidelines?" and ask if you can have a print out of their guidelines. In that way you will be covered for something like this as long as you follow it. If they say they do not have any, ask for that in writing too, the best way not to get screwed over is having it in writing one way or the other. I would get that from him, if possible, and bring up the argument that "if there is no clear route for me to follow, how can I follow it?" argument. I will definitely do this in the future, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299621 Share on other sites More sharing options...
Philip Posted December 20, 2011 Share Posted December 20, 2011 From my professors in College, they always told me that you should not have to comment "common sense" code, but more or less tricky code. I got marked down for over commenting, and after they clarified that, I never got mark downs for that again. Man, mine always told me the opposite... but this is why I say: that in a university you cater to the professor's opinions & preferences, rather than best practices Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299853 Share on other sites More sharing options...
MasterACE14 Posted December 21, 2011 Author Share Posted December 21, 2011 From my professors in College, they always told me that you should not have to comment "common sense" code, but more or less tricky code. I got marked down for over commenting, and after they clarified that, I never got mark downs for that again. Man, mine always told me the opposite... but this is why I say: that in a university you cater to the professor's opinions & preferences, rather than best practices Well at the end of the day, they're the ones marking it. Quote Link to comment https://forums.phpfreaks.com/topic/253442-fair-marking/#findComment-1299958 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.