Help With Assignments

Got confusion or query ???

Looking for customized, unused and Plagiarism free solutions ???

Submit your assignment here

.00

Keywords

CSC2402 Assignment 1 Full mark = 100% and is equivalent to 7 % of course mark. Submit your assignment on-line using the course web page. Assignment 1 consists of three tasks. You have to submit nine files including one documentation file in plain text format and eight C++ .pp files The .cpp files should have the program code and comments about the algorithm and the coding. We may compile the .cpp files using MinGW 4.7.1 if required. Our discussions and marking will base on MinGW 4.7.1 only. Outputs from sample runs for all programs should be grouped under a documentation file. All files must be in pure text format with “cpp” or “txt” extension. No PDF, HTML, Word, Open Office, RTF etc. files and no compression or archiving such as zip, rar, tar etc. Files other than in .cpp and .txt format will be ignored and no re-submission will be allowed. If you are using Codelite, the screen messages can be copied and pasted with the usual crtl-c and crtl-v. For output of sample runs, right click the title bar of the command window, select EDIT/MARK and then highlight the output. With the output selected, right click the title bar of the command window, select EDIT/COPY. Position your cursor to a (new) text file opened in a text editor such as Notepad, and crtl-v will paste the copied output to the text file. If you are using MinGW, right click the title bar of the command window; select EDIT/MARK and then high light the output. With the output selected, right click the title bar of the command window, select EDIT/COPY. Position your cursor to a (new) text file opened in a text editor such as Notepad, and crtl-v will paste the copied output to the text file. If you are using Linux, you can cut and paste the output from the terminal window to the input area of a text editor such as vim. You have to submit 9 files: • get_int_return.cpp. • get_int_return_checked.cpp. • get_int_ref.cpp. • get_int_ref_checked.cpp. • get_word_ref.cpp. • get_string_ref.cpp. • task2.cpp. • task3.cpp. • documentation.txt DO NOT zip / compress / archive / encrypt / password protect the files. Background information Roman digits Roman Digit I V X L C D M Decimal Value 1 5 10 50 100 500 1000 Rules for forming Roman numerals: Decimal Value 1 2 3 4 5 6 7 8 9 10 Roman Numeral I II III IV V VI VII VIII IX X Decimal Value 10 20 30 40 50 60 70 80 90 100 Roman Numeral X XX XXX XL L LX LXX LXXX XC C Decimal Value 100 200 300 400 500 600 700 800 900 1000 Roman Numeral C CC CCC CD D DC DCC DCCC CM M Decimal Value 1000 2000 3000 Roman Numeral M MM MMM Example: 2402 = 1000 + 1000 + 400 + 2 = M M CD II = MMCDII Example: 1748 = 1000 + 700 + 40 + 8 = M DCC XL VIII = MDCCXLVIII Rules for interpreting Roman numerals: Starting from left, if the digital value of the current numeral is not less than ( =) the next numeral • Add the digital value of the numeral to the output; • Otherwise subtract the digital value of the numeral from the output. Add to the output if the numeral is the last numeral. Example: MMCDII Starting with value n = 0; Step 1: M = M ? n += M = 1000 Step 2: M = C ? n += M = 2000 Step 3: C D ? n -= C = 1900 Step 4: D = I ? n += D = 2400 Step 5: I = I ? n += I = 2401 Step 6: last numeral ? n += l = 2402 Example: MDCCXLVIII Starting with value n = 0; Step 1: M = D ? n += M = 1000 Step 2: D = C ? n += D = 1500 Step 3: C = C ? n += C = 1600 Step 4: C = X ? n += C = 1700 Step 5: X L ? n -= X = 1690 Step 6: L = V ? n += L = 1740 Step 7: V = I ? n += V = 1745 Step 8: I = I ? n += 1 =1746 Step 9: I = I ? n += 1 = 1747 Step 10: last numeral ? n += 1 = 1748 Task 1 (20%) Question 1 (3 %) Implement get_int_return(): /** Get integer input from keyboard. Assumption: the input is always an integer. Prompt: “Please enter an integer: “ @return the integer input from keyboard. */ int get_int_return(); You may test your get_int_return() using the following program get_int_return.cpp: #include iostream #include string using namespace std; int get_int_return(); int main() { int n = 0; cout get_int_return() endl; return 0; } int get_int_return(){ // Your code } Submit the completed get_int_return.cpp. Question 2 (3%) Implement get_int_return_checked(): /** Get integer input from keyboard. If the input is negative or larger than 3999, it will ask for keyboard input again. Assumption: the input is always an integer. Prompt: “Please enter a number n: 0 n 4000: “ @return the integer input from keyboard. */ int get_int_return_checked(); Write get_int_return_checked.cpp to test your get_int_return_checked(). Submit get_int_return_checked.cpp. Question 3 (3 %) Implement get_int_ref(): /** Get integer input from keyboard. Assumption: the input is always an integer. Prompt: “Please enter an integer: “ @param n: integer input from keyboard. */ void get_int_ref(int& n); Write get_int_ref.cpp to test your get_int_ref(). Submit get_int_ref.cpp. Question 4 (4%) Implement get_int_ref_checked(): /** Get integer input from keyboard. If the input is negative or larger than 3999, it will ask for keyboard input again. Assumption: the input is always an integer. Prompt: “Please enter a number n: 0 n 4000: “ @param n: the integer input from keyboard. */ void get_int_ref(int& n); Write get_int_ref_checked.cpp to test your get_int_ref_checked(). Submit get_int_ref_checked.cpp. Question 5 (3 %) Implement get_word_ref(): /** Get a single word input from keyboard. Assumption: the input is always a single word. Prompt: "Please enter a word: " @param s: word input from keyboard (one word string). */ void get_word_ref(string& s); Write get_word_ref.cpp to test your get_word_ref(). Submit get_word_ref.cpp. Question 6 (4 %) Implement get_string_ref(): /** Get a string input from keyboard. Assumption: the input is always a valid string. Prompt: "Please enter a string: " @param s string input from keyboard. */ void get_string_ref(string& s); Write get_string_ref.cpp to test your get_string_ref(). Submit get_string_ref.cpp. Task 2 (40%) Write a program task2.cpp that converts positive integers less than 4000 to Roman numerals. Your program should: • Assume all inputs are integers; • Prompt user to input an integer n (0 = n 4000); • Use get_int_ref_checked() to get user input; • Program terminates if the user input is 0 (zero); • Call the function string int_to_ROMAN(int) to convert the user input to a Roman numeral; • Display the returned value from int_to_ROMAN(); • Repeat the above steps until a “0” (zero) is entered and the program will terminate. Your program should not • Use printf(), scanf(); • Display output in int_to_ROMAN(); • Terminate when user input is negative; • Terminate when user input is larger than 3999; You have to implement and use the function int_to_ROMAN(): /** Converts a positive integer less than 4000 to Roman numeral. @param n: integer; 0 n 4000. @return Roman numeral as a string with value equal to n. */ string int_to_ROMAN(int n); Test run should include: 1024, 2014, 1965, 82. Submit task2.cpp. Marking Scheme: Criteria Marks Get user input correctly 2% Implement function string int_to_ROMAN(int) correctly; 15% Use int_to_ROMAN (int) correctly 2% Program compiles AND runs correctly 15% Sample runs for program which runs correctly 2% Program layout for program which runs correctly 2% Comments for program which runs correctly 2% Note: • Program layout – see text book for examples. • Comments – brief explanation of what you are doing and why you do it this way. One or few lines will do. Do not write pages. Task 3 (40%) Write a program task3.cpp that converts valid Roman numerals to integers. Your program should: • Assume all inputs are valid Roman numerals; • Prompt user to enter a valid Roman numeral; • Use get_word_ref() to get user input assuming the input is always a valid Roman numeral or “END”; • Program terminates if the user input is “END”; • Call the function int ROMAN_to_int(string); to convert the user input to an integer; • Display the returned value from ROMAN_to_int(); • Repeat the above steps until an “END” is entered and the program will terminate. Your program should not • Use printf(), scanf(); • Display output in ROMAN_to_int(); You have to implement and use the function ROMAN_to_int(): /** Converts a Roman numeral to an integer. @param s: Roman numeral. @return integer with value equal to s. */ int ROMAN_to_int(string s); Submit task3.cpp. Marking Scheme: Criteria Marks Get user input correctly 2% Implement function int ROMAN_to_int(string) correctly; 15% Use ROMAN_to_int(int) correctly 2% Program compiles AND runs correctly 15% Sample runs for program which runs correctly 2% Program layout for program which runs correctly 2% Comments for program which runs correctly 2% Note: • Program layout – see text book for examples. • Comments – brief explanation of what you are doing and why you do it this way. One or few lines will do. Do not write pages. *** End of assignment 1 ***

Question Set #333

Views: 281
File Format: Microsoft Word Document with screenshots of program execution
Rest all files are in .cpp format
Editable: Yes

All files are in RAR Archive

Attachment: Click here to download