Directions Help

Recommended Videos

TheRundownRabbit

Wicked Prolapse
Aug 27, 2009
3,825
0
0
I am having a bit of trouble interpreting these directions for a C++ program.

To be specific, the parts in the brackets.

"We will make a simple, menu-driven math software package, call it Matlab Junior. Our software package will present the user with a menu of choices and execute the math function specified. The menu will look something like this:
MatLab Junior
[ 1) Print out prime numbers up to a pre-specified number ]
2) Compute X raised to the Y power
3) Absolute value of a number
4) The value of the hypotenuse of a right triangle.
5) Quit the Program
[ Please enter a number (1-5) -> ] "
 

Iyon

Recovering Lurker
May 16, 2012
106
0
0
It sounds like the program should display the menu you were given and then the user will select which option they want by entering a number 1-5. You would then prompt the user for the necessary values based on their selection. For example, if they enter "2" for "Compute X raised to the Y power", then you could prompt for X and Y and call a function that returns X raised to the Y power and display the result.

Regarding "1) Print out prime numbers up to a pre-specified number", you would prompt for a number and then generate all the prime numbers up to the specified number. For example, if the user entered "30", the prime numbers up to 30 would be: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.

I'm not sure if that's any help so I'll give an example of what I think the program's probably supposed to look like (user input bolded for clarity):

1) Print out prime numbers up to a pre-specified number
2) Compute X raised to the Y power
3) Absolute value of a number
4) The value of the hypotenuse of a right triangle.
5) Quit the Program
Please enter a number (1-5) -> 1


Enter a number: 30
Result: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29