Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you please help me write this numerology function into my code I wrote alrea

ID: 3598868 • Letter: C

Question

Can you please help me write this numerology function into my code I wrote already?

Instructions:
Add a function called numerology that will use a person's date of birth to try and determine some traits about the person by using some basic principles of numerology. The function should take no arguments and returns nothing.

The user should be prompted for their date of birth, which will then be used to calculate the Life Path number. The user should enter the date in the format: mm/dd/yyyy where mm is the 2-digit month, dd is the 2-digit day, and yyyy is the 4-digit year. One way to read in the date is as follows:

int month, day, year;
cout << "Enter your birthdate in the form (mm/dd/yyyy): ";
cin >> month;    //get the month value from the input buffer
cin.ignore();    //remove the 1st / from the input buffer
cin >> day;      //get the day value from the input buffer
cin.ignore();    //remove the 2nd / from the input buffer
cin >> year;     //get the year value from the input buffer

To calculate the Life Path number, calculate the sum of the month, day, and year from the date of birth. If the sum is a single digit value, the Life Path number has been calculated. If it's not, continually add the digits of the sum until a single digit value is obtained. For example:

Birthdate: 10/28/1955            Birthdate: 11/30/1977
10 + 28 + 1955 = 1993            11 + 30 + 1977 = 2018
1 + 9 + 9 + 3 = 22               2 + 0 + 1 + 8 = 11
2 + 2 = 4                        1 + 1 = 2

Life Path number: 4              Life Path number: 2

The display should be neat and easy to read. Once the Life Path number has been calculated, use it to display some traits about the person based on the following:
Life path # Traits
1   individualistic, independent, and show leadership and drive
2   sensitive, tactful, diplomatic, and cooperative
3   creative and a good communicator
4   natural planner, fixer, and builder
5   energetic, adventurous, daring, and freedom-loving
6   responsible, loving, self-sacrificing, protective, and compassionate
7   gift for investigation, analysis, and keen observation
8   skills to lead, direct, organize and govern
9   helpful, compassionate, sophisticated and generous

Once the above program is completed, could you please add it in the correct spot to my code below? THANKS!

#include <iostream>

#include <iomanip>

#include <cstdlib>

#include <ctime>

using namespace std;

const int NUM_VALS = 10; //the maximum number of values to use

//function prototypes

int reverse(int num);

bool isPrime(int num);

bool isPalindrome(int num);

int sumDigits(int num);

int main()

{

int number, //Holds the random number that is manipulated and tested

loopCnt; //Controls the loop

  

//set the seed value for the random number generator

//Note: a value of 1 will generate the same sequence of "random" numbers every

// time the program is executed

srand(1);

  

//Generate 10 random numbers to be manipulated and tested

for (loopCnt = 1; loopCnt <= NUM_VALS; loopCnt++)

{

//Get a random number

number = rand();

  

//Display the sum of adding up the digits in the random number, the reversed

//random number, and whether or not the number is palindromic or a prime number

  

cout << "The number is " << number << endl

<< "----------------------------------------" << endl

<< "Adding the digits result" << setw(16) << sumDigits(number) << endl

<< "Reversing the digits result" << setw(13) << reverse(number) << endl

<< "Is the number a palindrome?" << setw(13) << (isPalindrome(number) ? "Yes" : "No") << endl

<< "Is the number prime?" << setw(20) << (isPrime(number) ? "Yes" : "No") << endl

<< endl << endl;

}

system("pause");

return 0;

}

int sumDigits(int num) //Creates function that will add up the digits of the random number

{

int sum = 0, rem;

while (num != 0) //Loop that will isolate each digit of the number using modulus division

{ // Will then add the isolated digit to sum and continue to ioslate the digits

rem = num % 10;

sum += rem;

num /= 10;

}

return sum;

}

int reverse(int num) //Creates function that will reverse the number

{

int reversed = 0;

int quo, rem;

quo = num;

while (quo != 0) //Loop will isolate single digits using modulus divsion and display them in reversed order

{

rem = quo % 10;

reversed = reversed * 10 + rem;

quo /= 10;

}

return reversed;

}

bool isPalindrome(int num) //Creates function that will check if the number is a palindrome

{

if (reverse(num) == num) //Calls reverse function and checks if the revsered number is a palindrome

return true;

else

return false;

}

bool isPrime(int num) //Creates function that will check if number is prime

{

int i;

  

if (num % 2 == 0) //if number is even, it will be checked here if it is prime

return false;

for (i = 3; i*i <= num; i += 2) //if number is odd it will be checked here

{

if (num % i == 0)

return false;

}

return true;

}

Explanation / Answer

Hi,

Please find the complete code below. I have created the numerology function and called it after for loop. In function definition, I have Logic for calculating LifePath number and Printing the trait based on LifePath number. You can also create seperate functon for the printing.

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;

const int NUM_VALS = 10; //the maximum number of values to use

//function prototypes
int reverse(int num);
bool isPrime(int num);
bool isPalindrome(int num);
int sumDigits(int num);
void numerology(void); //Numerology function

int main()
{
int number, //Holds the random number that is manipulated and tested
loopCnt; //Controls the loop
  
//set the seed value for the random number generator
//Note: a value of 1 will generate the same sequence of "random" numbers every
// time the program is executed
srand(1);
  
//Generate 10 random numbers to be manipulated and tested
for (loopCnt = 1; loopCnt <= NUM_VALS; loopCnt++)
{
//Get a random number
number = rand();
  
//Display the sum of adding up the digits in the random number, the reversed
//random number, and whether or not the number is palindromic or a prime number
  
cout << "The number is " << number << endl
<< "----------------------------------------" << endl
<< "Adding the digits result" << setw(16) << sumDigits(number) << endl
<< "Reversing the digits result" << setw(13) << reverse(number) << endl
<< "Is the number a palindrome?" << setw(13) << (isPalindrome(number) ? "Yes" : "No") << endl
<< "Is the number prime?" << setw(20) << (isPrime(number) ? "Yes" : "No") << endl
<< endl << endl;
}
numerology(); //Called the numerology function
system("pause");
return 0;
}

int sumDigits(int num) //Creates function that will add up the digits of the random number
{
int sum = 0, rem;
while (num != 0) //Loop that will isolate each digit of the number using modulus division
{ // Will then add the isolated digit to sum and continue to ioslate the digits
rem = num % 10;
sum += rem;
num /= 10;
}
return sum;
}

int reverse(int num) //Creates function that will reverse the number
{
int reversed = 0;
int quo, rem;
quo = num;
while (quo != 0) //Loop will isolate single digits using modulus divsion and display them in reversed order
{
rem = quo % 10;
reversed = reversed * 10 + rem;
quo /= 10;
}
return reversed;
}

bool isPalindrome(int num) //Creates function that will check if the number is a palindrome
{
if (reverse(num) == num) //Calls reverse function and checks if the revsered number is a palindrome
return true;
else
return false;
}

bool isPrime(int num) //Creates function that will check if number is prime
{
int i;
  
if (num % 2 == 0) //if number is even, it will be checked here if it is prime
return false;
for (i = 3; i*i <= num; i += 2) //if number is odd it will be checked here
{
if (num % i == 0)
return false;
}
return true;
}

void numerology() //function that will use a person's date of birth to try and determine some traits about the person by using some basic principles of numerology
{
int month, day, year;
cout << "Enter your birthdate in the form (mm/dd/yyyy): ";
cin >> month; //get the month value from the input buffer
cin.ignore(); //remove the 1st / from the input buffer
cin >> day; //get the day value from the input buffer
cin.ignore(); //remove the 2nd / from the input buffer
cin >> year; //get the year value from the input buffer
int total = day + month + year;

int sum = 0, rem, num = total, lifePath,sum2 = 0;


sum = sumDigits(num); //calling sumDigits to sum all digits of total
cout << "Total is: " << total << " and sum is: " << sum << endl;
if(sum < 10)
{
lifePath = sum; //If sum is less than 10 then lifepath is sum
}
else
{

sum2 = sumDigits(sum); //Calling sumDigits again to add digits of obtained sum
lifePath = sum2;
}

switch(lifePath) { //Print traits based on lifePath Number
case 1 :
cout << "Your LifePath Number is 1, That means You are individualistic, independent, and show leadership and drive" << endl;
break;
case 2 :
cout << "Your LifePath Number is 2, That means You are sensitive, tactful, diplomatic, and cooperative" << endl;
break;
case 3 :
cout << "Your LifePath Number is 3, That means You are creative and a good communicator" << endl;
break;
case 4 :
cout << "Your LifePath Number is 4, That means You are natural planner, fixer, and builder" << endl;
break;
case 5 :
cout << "Your LifePath Number is 5, That means You are energetic, adventurous, daring, and freedom-loving" << endl;
break;
case 6 :
cout << "Your LifePath Number is 6, That means You are responsible, loving, self-sacrificing, protective, and compassionate" << endl;
break;
case 7 :
cout << "Your LifePath Number is 7, That means You have a gift for investigation, analysis, and keen observation" << endl;
break;
case 8 :
cout << "Your LifePath Number is 8, That means You have skills to lead, direct, organize and govern" << endl;
break;
case 9 :
cout << "Your LifePath Number is 9, That means You are helpful, compassionate, sophisticated and generous" << endl;
break;
default :
cout << "Invalid LifePath Number" << endl;
}


}