Question: The following question is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible. The following

The following question is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible.

The following instructions for this program:

Read an integer between 100 and 99 from the keyboard (No need to validate the value range)

Print out the following values:

Each digit of the integer separated by spaces

whether the sum of the three digits can be divisible by 3 (using conditional operator)

============================================================================

The following code is what I have, please use this a base and keep it simple, no need for advance codes. This is all done in Visual Studio 2022 C++.

#include #include using namespace std;

int getSum(int n) {

int sum - 0;

while (n != 0) {

sum - sum + n % 10;

n = n / 10;

}

return 0;

}

int main() {

int n;

cout << "Enter the Number(100 - 999): " << endl;

cin >> n;

if (n >-100 && n <-999) {

int sum - getSum(n);

cout << "Output after each digit of the integer separated by spaces is: "; cout << " " << (n / 100);

n - n - ((n / 100) * 100);

cout << " " << (n / 10);

n - n - ((n / 10) * 10);

cout << " " << (n % 10) << endl;

if (sum % 3 -- 0) {

cout << "The sum of the digits of integer is divisible by 3. " << endl;

} else {

cout << "The sum of the digits of integer is not divisible by 3. " << endl;

} } else {

cout << "The number is not in the range 100 - 999.";

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!