? GET 262 (COMPUTER PROGRAMMING II) Coursework Grading (Algorithm: 70%, Code: 30
ID: 3688648 • Letter: #
Question
?
GET 262 (COMPUTER PROGRAMMING II) Coursework
Grading (Algorithm: 70%, Code: 30%)
This coursework will count towards 25% of your final mark.
This coursework is due on April 27th, 2016
Submission mode: Each group should submit a compressed folder containing a C++ file (for source code) and Microsoft World file (for report). Attach compressed folder and email to tahir.aduragba@kwasu.edu.ng with “GET 262 Coursework” as email subject.
The law requires that food product manufacturers place expiration dates on their products, but there is a loophole in the law: it does not require the expiration date to be in any particular form. So, it can be written in Swahili and still be legal.
Ralph Nader's third cousin, Nadine is a self-appointed Food Quality Spy. She has learned that many food product manufacturers have started encoding the product expiration dates to keep customers from knowing how old the stuff is.
But the encoding does allow grocers to figure out the expiration dates if for some reason, they want to.
One popular encoding method:
Encode the months from Jan to Dec as 'A' through 'L'
Encode each digit of the date as 'Q' through 'Z'
Encode the year as 'A' through 'Z' meaning 1 through 26, which is then added to 1995.
Nadine found a particularly questionable loaf of bread with this date: ARZM. Write a program using functions to determine the date.
How to: Write a Programming Report by F. P. Hargreaves (2011).
The report should contain the following sections:
Specification
Describe the task at hand. Makes sure to distinguish between the given problem and your own additional goals (if any). Possible refer to the project description. Be very brief and concise.
Design
Describe the algorithm(s) that was (were) designed. Avoid describing how the design was produced; rather show different versions of the design if relevant. Use pseudo code or flow chart to avoid ambiguity.
Implementation
Show the implementation. The goal of this section is to show and explain the most important parts of the code. Listing the code with highlighting and possibly line numbering is essential. Explain the code by refereeing to line numbers, function calls and variable names. Leave out trivial parts (initialisation, parameter-tuning etc.…)
Conclusion
Describe to which the degree the product meets the requirements of the project. If relevant, describe how the performance of the product compares to your expectations.
Appendices
Full source code listing
Explanation / Answer
#include <iostream>
using namespace std;
string decode_month(const char month);
int decode_digit(const char day);
int decode_year(const char year);
int main(){
string in;
cout << "Enter a coded date." << endl;
if( !(cin >> in)){
cout<< "Error reading the date." << endl;
} else {
cout << "DD/MM/YYYY: " << decode_digit(in.substr(1,1)[0]) << decode_digit(in.substr(2,1)[0]) << "/" << decode_month(in.substr(0,1)[0]) << "/" << decode_year(in.substr(3,1)[0]) << endl;
}
}
int decode_year(const char year){
return 64 - year + 1995;
}
int decode_digit(const char day){
return day - 81;
}
string decode_month(char month){
string decode;
int base = month - 64;
switch(base){
case 1:
decode = "Jan";
break;
case 2:
decode = "Feb";
break;
case 3:
decode = "Mar";
break;
case 4:
decode = "Apr";
break;
case 5:
decode = "May";
break;
case 6:
decode = "Jun";
break;
case 7:
decode = "Jul";
break;
case 8:
decode = "Aug";
break;
case 9:
decode = "Sept";
break;
case 10:
decode = "Oct";
break;
case 11:
decode = "Nov";
break;
case 12:
decode = "Dec";
break;
default:
cout << "Error in month: " << decode << endl;
}
return decode;
}
sample output
Enter a coded date.
12/01/1991
Error in month:
DD/MM/YYYY: -31-34//2011
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.