Programming Assignment 6 CSCI 251 For program 6, we will revisit program 3, and
ID: 3820813 • Letter: P
Question
Programming Assignment 6 CSCI 251 For program 6, we will revisit program 3, and rewrite it using two functions instead. On Blackboard, download the program unction.m You must use this main program when writing your two functions. If you alter this program in any way, it will result in an automatic o for the programming assignment. So, be sure to use the same function names as indicated in this main program, as well as the same number of parameters & return values. Function 1 name: monthNumber.m Parameters: the four inputs: add8, add4, add2, add1 Return value: sum of the sets for which the user entered y within function using an if statement, determine & return the sum (this can be 0 to 15) Function 2 name: monthName.m Parameter: the sum determined in monthNumber Return Value: the name of the month within function 2, using a switch statement, determine & return the name of the month. Note that no additional code needs to be included from program 3 other than the function header. This program is about re-arranging the code Only submit your two functions on Blackboard. include header comments formatted exactly as shown below but with your name, student ID, and section number (i.e., these comments should be the FIRST LINES in your script). Be sure to include the Honor Code statement. Your electronic submission of the program file will represent your endorsement of the Honor Code Statement. CSCI 251, Section X Jane Doe Student ID 12345678 Programming Assignment 6 Due In keeping with the Honor Code of UM, I have neither given nor received assistance from anyone other than the instructor. Put a program description here Before each significant step, provide a comment explaining the step (do not comment every line of code). Twenty percent per day (or any part of a day) will be deducted for late programming assignments.Explanation / Answer
The two functions are as follows:
Function 1:
int monthNumber.m(int add8,int add4,int add2,int add1) //the parameters accept either 0 or 1
{
int sum=0;
if(add8==1)
sum+=8;
if(add4==1)
sum+=4;
if(add2==1)
sum+=2;
if(add1==1)
sum++;
return sum;
}
Function 2:
String monthName(int sum)
{
String name;
switch(sum)
{
case 1:
name="January";
break;
case 2:
name="February";
break;
case 3:
name="March";
break;
case 4:
name="April";
break;
case 5:
name="May";
break;
case 6:
name="June";
break;
case 7:
name="July";
break;
case 8:
name="August";
break;
case 9:
name="September";
break;
case 10:
name="October";
break;
case 11:
name="November";
break;
case 12:
name="December";
}
return name;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.