I honestly don't understand what my teacher is asking me to do, but here's the question, maybe someone can comprehend what the question is, because I sure don't:
Review 4 Part 1: Write a function SpanishNum(int num) that displays the Spanish equivalent of it's int parameter that is in the range 1 to 5. To test this function, complete Review 4 Part 2, then print the complete program and turn in. :
1 uno
2 dos
3 tres
4 quattro
5 cinco
WAIT!! You are not done yet!!!!!!!!! Now write this main to test the SpanishNum() ->
Review 4 Part 2: Write a program where main() uses a for loop to display a table similar to the one above by calling SpanishNum() inside the loop. You do not need to cin() any data!!!!
I honestly have no clue what she's asking us to do.
Actually I figure that for the first part, I'm supposed to make the for something like (int a = 0; a > 5; a++) and make a switch making 1-5 cout a string.
I am seeing a whole loop with if statements at the values of 1-2-3-4-5-6-7-8-9-10-20-30-40-50-60-70-80-90-100. To this will be a function that uses a switch or a set of if statements that convert a number to Spanish. For example.
While(num >0){
switch(num):
Case 1: std::cout << "UNO";
Num--;
Break;
Expand on that. Typing on my phone so sorry about that format.
@atropos (bane elemental?), it's asking for a for statement and that no user input is required, so I'm just assuming what I have below is what she's asking for..
#include<iostream>
usingnamespace std;
//
void SpanishNum();
//
int main(){
SpanishNum();
system("PAUSE");
}
//
void SpanishNum()
{
for(int num = 0; num <= 5; ++num)
{
switch( num )
{
case 1:
cout << num << " UNO \n";
break;
case 2:
cout << num << " DOS \n";
break;
case 3:
cout << num << " TRES \n";
break;
case 4:
cout << num << " QUATRO \n";
break;
case 5:
cout << num << " CINCO \n";
break;
}
}
}
Move the loop inside SpanishNum() into main(), and add one "int" parameter to SpanishNum. In main(), pass the int used in the for loop to SpanishNum().
Oh, I thought part 1 question and part 2 question were separate.
Since your teacher wants you to call SpanishNum(int) from inside the for loop in main, you need to make a simple loop with a counter variable that ranges from 1 to 5, and for each pass of the loop, SpanishNum is called using the counter variable as the argument.
#include<iostream>
usingnamespace std;
//
int SpanishNum(int num);
//
int main(){
for(int num = 0; num <= 5; ++num)
SpanishNum();
system("PAUSE");
}
//
int SpanishNum(int num)
{
switch(num)
{
case 1:
cout << num << " UNO \n";
break;
case 2:
cout << num << " DOS \n";
break;
case 3:
cout << num << " TRES \n";
break;
case 4:
cout << num << " QUATRO \n";
break;
case 5:
cout << num << " CINCO \n";
break;
}
return(num);
}
@atropos, considering it's not a void, I feel like it's meant to return something, but it seems like the program could do the same thing without a return.
and nevermind, Atropos is the name of a hero from a game called DoTA :P
Since the function prints out the spanish words itself, it really has no need to return a value. I was just asking whether is was supposed to be void because in one post, you declare it as void SpanishNum(int); and in another itsint SpanishNum(int);