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

Write a C++ program that asks user to enter a positive odd integer 9 <= num <= 1

ID: 3863372 • Letter: W

Question

Write a C++ program that asks user to enter a positive odd integer 9 <= num <= 15. If the input value is incorrect, the program repeatedly force user to input values until num is within the expected value.The program then prints out two big “asterisks” with four spaces in between like below.

Sample run with user's input shown in bold: Enter an odd integer between 9 and 15 (inclusive) 17 Enter an odd integer between 9 and 15 (inclusive) 7 Enter an odd integer between 9 and 15 (inclusive) 10 Enter an odd integer between 9 and 15 (inclusive) 11 *&* *&* *&* *&*

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
    int num;
    while(true){
        cout << "Enter an odd number between 9 and 15 (inclusive) :";
        cin >> num;
       if(num%2==1 && num >= 9 && num <= 15)
            break;
    }
    cout <<"*    $    * "; cout <<"*    $    *"<<endl;
    cout <<" *   $   *   "; cout <<" *   $   * "<<endl;
    cout <<" * $ *    "; cout <<" * $ * "<<endl;
    cout <<"   * $ *     "; cout <<"   * $ *   "<<endl;
    cout <<"    *$*      "; cout <<"    *$*    "<<endl;
    cout <<"XXXXX*+++++ "; cout <<"XXXXX*+++++"<<endl;
    cout <<"    *$*      "; cout <<"    *$*    "<<endl;
    cout <<"   * $ *     "; cout <<"   * $ *   "<<endl;
    cout <<" * $ *    "; cout <<" * $ * "<<endl;
    cout <<" *   $   *   "; cout <<" *   $   * "<<endl;
    cout <<"*    $    * "; cout <<"*    $    *"<<endl;
  
   return 0;
}

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