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

Hi, I have done the first part of this assignment. All I need is to do the last

ID: 3648935 • Letter: H

Question

Hi, I have done the first part of this assignment. All I need is to do the last paragraph part for adding necessary code for four digit, five digit and six digit numbers and state that the number is wrong if they're not 4,5,6 digits. Here is my code for the three digit integer, which works fine:


#include <iostream>

using std::namespace;


int main ()

{

int threeDigit, i = 10, j= 100, high, low;

cout << "Please enter a three digit integer: ";

cin >> threeDigit;

while (threeDigit < 100 || threeDigit > 999 )

{

cout << "Number must be three digits. ";

cout << "Enter a three digit number: ";

cin >> threeDigit;

}

cout << threeDigit;

while (threeDigit > 10)

{

low = threeDigit % i;

high = threeDigit / j;

if (low != high)

{

cout << " Number is not a palindrome. ";

return 0;

}

threeDigit = (threeDigit - (high * j)) / 10;

j /= 100;

}

cout << " Number is a palindrome. ";

return 0;

}



A palindrome is a number or text phrase that reads the same backwards as forwards. The integer 454 is an example of a three-digit palindrome because the first and last digits are a match. 2442 is an example of a four-digit palindrome because the first digit matches the last digit and the second digit matches the third digit. 12321 is an example of a five-digit palindrome and 246642 is an example of a six-digit palindrome.

Begin by writing a program that will read an integer and determine whether it is a three-digit palindrome. If the user enters an integer that is not three-digits, display an appropriate error message and end the program.

In order to determine the number of digits, consider the smallest three-digit integer. Now consider the largest possible three-digit integer. These two values will define the range for three-digit integers. The program must determine if the integer entered by the user falls within this range; use the logical operators in this endeavor.

Use the integer division and modulus operators to determine the individual digits of the number.

Once the program is working correctly with three-digit integers, add the necessary to code to make the program work for four-, five-, and six-digit integers as well. If the user enters an integer that is not three, four, five, or six digits in length, the program should display an appropriate error message and end the program.

Explanation / Answer

#include using namespace std; /*Once the program is working correctly with three-digit integers, add the necessary to code to make the program work for four-, five-,and six-digit integers as well. If the user enters an integer that is not three, four, five, or six digits in length, the program should display an appropriate error message and end the program.*/ int main () { // char wait; int num,high=0, low=0,i,j; //while(1){ coutnum; while(num999999){ cout num; */ return 0; } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote