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

IN C++ ONLY - First, you must prompt the user to enter two numbers greater than

ID: 3750829 • Letter: I

Question

IN C++ ONLY - First, you must prompt the user to enter two numbers greater than 1 and less than 11. Continue to prompt them until they enter two valid numbers.

To meet the specifications of Part II below, do not give any prompt such as "Enter a number". The user will know to enter a number. But you must ensure the values are within the proper range and continue to receive input until the number is valid.

Then output a multiplication table. You'll need to print out the column and row headers so we know what two values are being multiplied. Then each cell will be the result of that product. Be sure to have the numbers right aligned with enough space to have all our columns aligned. Fill the empty space with a period to ensure the columns are properly aligned.

Note that the program uses the first two valid values entered as the multipier and multiplicand (5 & 7). When developing your program, you should continually prompt the user until they enter a valid number. Then continually prompt them again until they enter a second valid number.

Hint: You'll need a couple of loops to accomplish this task. And recall, the iomanip library will help you with aligning the columns.

Recall that the user can enter values within the range 2 to 10 inclusive, so be sure to allocate enough space to handle a 10x10 multiplication table.

Explanation / Answer

PROGRAM

#include<iostream>

#include<iomanip>

using namespace std;

int main()

{

int a,b; // declare two variables

while(1) // create infinite while loop until input is valid

{

cin>>a; // read a

cin>>b; // read b

if(a>=1&&a<11&&b>=1&&b<11) // check condition a and b in between 1 to 10

{

for(int i=1;i<=a;i++) // create for loop until a range

{

cout<<setw(5); // display space

for(int j=1;j<=b;j++) // create for loop until b range

cout<<i*j<<setw(5); // display multiply (a*b)value with space

cout<<endl; // next line

}

break; // if sucussful enter ranges then break from while loop

}

}

return 0;

}

OUTPUT

1
12
15
2
11
2
5
7
1 2 3 4 5 6 7
2 4 6 8 10 12 14
3 6 9 12 15 18 21
4 8 12 16 20 24 28
5 10 15 20 25 30 35