Write a C++ program that does the following :
Define a class myInt that has as its single attribute an integer variable and that contains member functions for determining the following information for an object of type myInt:
A. Is it multiple of 7 , 11 , or 13.
B. Is the sum of its digits odd or even.
C. What is the square root value.
D.Is it a prime number.
E. Is it a perfect number ( The sum of the factors of a perfect number is equal to the number itself – for example : 1 + 2 + 4 + 7 + 14 = 28 , so 28 is a perfect number ).
F. All of the above.
Z. Exit Write a interface that tests your functions
NOTES:
• Just one .cpp ( Header file , implementation of header file and the interface all in one program)
• Must define a class with at least 6 functions. • Do not use arrays … etc.
• Validation on the menu selection.
• Validation on the integer value that is entered by the user.
• Free output format.
• Test your functions by entering values such as 104 , 3773 , 13 , 121 , 77 , 3075
#include <iostream>
#include<math.h>
using namespace std;
class Special_Number
{
private:
int myInt;
public:
Special_Number(int num)
{
this->myInt=num;
}
void isMultiple()
{
if(myInt%7==0)
{
cout<<"Its a multiple of 7"<<endl;
}
else
{
cout<<"Its not a multiple of 7"<<endl;
}
if(myInt%11==0)
{
cout<<"Its a multiple of 11"<<endl;
}
else
{
cout<<"Its not a multiple of 11"<<endl;
}
if(myInt%13==0)
{
cout<<"Its a multiple of 13"<<endl;
}
else
{
cout<<"Its not a multiple of 13"<<endl;
}
}
void sumOfDigitsOddEven()
{
int num = myInt;
int sum=0;
while(num!=0)
{
sum +=num%10;
num = num/10;
}
if(sum%2==0)
{
cout<<"Sum of digits is even"<<endl;
}
else
{
cout<<"Sum of digits is odd"<<endl;
}
}
void squareRoot()
{
cout<<"Square Root is:
"<<sqrt(myInt)<<endl;
}
void perfectNumber()
{
int factorSum=0;
for(int i=1; i<=myInt/2; i++)
{
if(myInt%i==0)
{
factorSum+=i;
}
}
if(factorSum==myInt)
{
cout<<"Its a perfect number"<<endl;
}
else
{
cout<<"Its not a perfect number"<<endl;
}
}
};
int main()
{
char choice;
int number;
cout<<"Enter a number to test: ";
cin>>number;
Special_Number aNumber(number);
cout<<"A. Is it multiple of 7 , 11 , or
13."<<endl;
cout<<"B. Is the sum of its digits odd or
even."<<endl;
cout<<"C. What is the square root value."<<endl;
cout<<"D.Is it a prime number."<<endl;
cout<<"E. Is it a perfect number"<<endl;
cout<<"F. All of the above."<<endl;
cout<<"Enter A, B, C, D, E, F --> ";
cin>>choice;
if (choice=='A')
{
aNumber.isMultiple();
}
else if(choice=='B')
{
aNumber.sumOfDigitsOddEven();
}
else if(choice=='C')
{
aNumber.squareRoot();
}
else if(choice=='E')
{
aNumber.perfectNumber();
}
else if(choice=='F')
{
aNumber.isMultiple();
aNumber.sumOfDigitsOddEven();
aNumber.squareRoot();
aNumber.perfectNumber();
}
else
{
cout<<"Invalid selection"<<endl;
}
}

Write a C++ program that does the following : Define a class myInt that has as...
C++
Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...
Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...
Write a C program which computes the count of the prime and perfect numbers within a given limit Land U, representing the lower and upper limit respectively. Prime numbers are numbers that have only 2 factors: 1 and themselves (1 is not prime). An integer number is said to be perfect number if its factors, including 1 (but not the number itself), sum to the number. Sample Inputi: 1 100 Sample Outputs: Prime: 25 Perfect: 2 Sample Input2: 101 10000...
***Program must compile under Ubuntu! (35 pts) Write a C++ program A4p3.cpp with a class that is a derived class of your class from problem 2. Add a private intmember variable var2 to this class. Initialize the member variables var and var2 with values between 1 and 50 using a constructor that takes two integer parameters. Add a public member function called getsp that should print out the sum and product of var and var2. In your main function, create...
(Please use C language, not C++) Determine the following information about each value in a list of positive integers. a. Is the value a multiple of 7, 11, or 13? b. Is the sum of the digits odd or even? (parameter output returns 0 for even, 1 for odd) c. Is the value a prime number? (parameter output returns 0 nonprime, 1 for prime) Use an output file for results. The goal is to implement both pass by value and...
Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...
Write a C++ program to define a class having a 4x4 matrix. Generate 32 random numbers 1-10, in an output.txt file. Fill the generated numbers in two such class objects (first 16 numbers in one matrix and next 16 numbers in another. Create member functions each for adding, subtracting and multiplication of matrices. Write the algorithm defining steps of your program.
Objectives:
1. Classes and Data Abstraction?2. User-defined classes?3.
Implementation of a class in separate files
Part 1:
In this assignment, you are asked:
Stage1:?Design and implement a
class named memberType
with the following requirements:
An object of memberType holds the following
information: • Person’s first name (string)?• Person’s last name
(string)?• Member identification number (int)
• Number of books purchased (int)?• Amount of money spent
(double)?The class memberType has member functions that
perform operations on objects of memberType. For the...
(i) Create a class square with attribute (integer) length which defaults to 5. Provide member functions that calculate the perimeter (4 * length) and the area (length*length) of the triangle. Also provide set and get functions for the length attribute. The set function should verify that length is between 0.0 to 100. Your class should also provide a display function that draws the aquare using * character. For example, if length = 5, the display function should draw *****...
C/C++ Final Project PROGRAM DUE MONDAY OF FINALS WEEK. Minimum requirements, the program must include the following features: Create a program that interacts with the user. Use at least 3 objects (instances of different classes) Use at least one example of inheritance Use at least one pointer Use at least one pass by reference Use at least one overloaded function Use separate files for class definition, class function definition, cpp file that has main Use at least 2 loops Use...