Question
IN C++ Write the definitions of the functions of the class primeFactorization ( Example 11-4 ) declared in the primeFactorization header file. Write a program
IN C++
Write the definitions of the functions of the class primeFactorization (Example 11-4) declared in the primeFactorization header file. Write a program that uses this class to output the prime factorization of an integer. Your program should prompt the user for an integer, determine if the input is a prime number, and display the factorization of the integer.
1) Program produces correct output for prime numbers
WHAT I NEED: main.cpp & primeFactorizationImp.cpp
PROVIDED CODE:
integerManipulation.h
#ifndef integerManipulation_H
#define integerManipulation_H
class integerManipulation
{
public:
void setNum(long long n);
//Function to set num.
//Postcondition: num = n;
long long getNum();
//Function to return num.
//Postcondition: The value of num is returned.
void reverseNum();
//Function to reverse the digits of num.
//Postcondition: revNum is set to num with digits in
// in the reverse order.
void classifyDigits();
//Function to count the even, odd, and zero digits of num.
//Postcondition: evenCount = the number of even digits in num.
// oddCount = the number of odd digits in num.
int getEvensCount();
//Function to return the number of even digits in num.
//Postcondition: The value of evensCount is returned.
int getOddsCount();
//Function to return the number of odd digits in num.
//Postcondition: The value of oddscount is returned.
int getZerosCount();
//Function to return the number of zeros in num.
//Postcondition: The value of zerosCount is returned.
int sumDigits();
//Function to return the sum of the digits of num.
//Postcondition: The sum of the digits is returned.
integerManipulation(long long n = 0);
//Constructor with a default parameter.
//The instance variable num is set accordingto the parameter,
//and other instance variables are set to zero.
//The default value of num is 0;
//Postcondition: num = n; revNum = 0; evenscount = 0;
// oddsCount = 0; zerosCount = 0;
private:
long long num;
long long revNum;
int evensCount;
int oddsCount;
int zerosCount;
};
#endif
==========================
integerManipulationImp.cpp
#ifndef primeFactorization_H
=============================
primeFactorization.h
#ifndef primeFactorization_H
#define primeFactorization_H
#include "integerManipulation.h"
class primeFactorization: public integerManipulation
{
public:
void factorization();
//Function to output the prime factorization of num
//Postcondition: Prime factorization of num is printed;
primeFactorization(long long n = 0);
//Constructor with a default parameter.
//The instance variables of the base class are set according
//to the parameters and the array first125000Primes is
//created.
//Postcondition: num = n; revNum = 0; evenscount = 0;
// oddsCount = 0; zerosCount = 0;
// first125000Primes = first 125000 prime numbers.
private:
long long first125000Primes[125000];
void primeFact(long long num, long long list[], int length,
int firstPrimeFactIndex);
void first125000PrimeNum(long long list[], int length);
//Function to determine and store the first 125000 prime
//integers.
//Postcondition: The first 125000 prime numbers are
// determined and stored in the array first125000Primes;
void primeTest(long long num, long long list[], int length,
bool& primeNum, int& firstPrimeFactIndex);
bool isPrime(long long number);
};
#endif
===========================
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started