Write a program that will ask the user to input an integer value. Your program should then determine if the integer value is an odd or even number. Depending on whether the number is odd or even, output the number is odd/even, and either divide or multiply the input number as shown in the process statement below. Also, see the sample output below.
Input - One whole number.
Process - Determine if the number is odd or even. When the number is odd multiply it by 12. When the number is even divided the number by 2.
Output - The input, if the input is odd or even, and the input either divided by 2 or multiplied by 12 and shown in an equation. Try to match the text and spacing shown in the sample output exactly.
Programming Details:
Use an if else construct and the modulus operator to determine if the number is evenly divisible by 2 and output the correct information and equation. The program should work correctly with any whole number input.
It should read out
Please enter a number: 4
the number 4 is an even number.
4 / 2 = 2
Please enter a number: 11
The number 11 is an odd number.
11 * 12 = 132
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
using namespace std;
int main ()
{
int x;
cout << " Please enter a number;" << endl;
cin >> x;
if (x%2 == 0)
{
cout << x << " is an odd number" << endl;
cout << x * 12 = << endl;
}
else
{
cout << x << " is an even number" << endl;
cout << x / 2 = << endl;
}
return 0;
}
|
what am not sure about is how do i ask the computer to determine if its a even or odd number?