Question: main.cpp / / CS 1 4 1 Lab 4 : Multiplication Table starter code. / / Complete the code to display all or part of

main.cpp
// CS 141 Lab 4: Multiplication Table starter code.
// Complete the code to display all or part of a multiplication table.
//
#include
#include // for setw()
using namespace std;
/*------------------------------------------------------------
Use a loop to display the numbers 1..10
Sample output:
Lab 4: Using loops
1. Show single row
2. Show multiplication table
3. Show a subset of a multiplication table
4. Exit the program.
Your choice (1-4)-->1
Enter the limit for the line of numbers: 8
Single line:
12345678
Done.
*/
void singleLine( int limit)
{
cout << "Single line:" << endl;
// Your code goes here
//...
}//end singleLine()
/*------------------------------------------------------------
Use a loop within a loop to display a multiplication table
Sample output:
Lab 4: Using loops
1. Show single row
2. Show multiplication table
3. Show a subset of a multiplication table
4. Exit the program.
Your choice (1-4)-->2
Multiplication Table:
12345678910
2468101214161820
36912151821242730
481216202428323640
5101520253035404550
6121824303642485460
7142128354249566370
8162432404856647280
9182736455463728190
102030405060708090100
Done.
*/
void allRowsAndColumns(int size)
{
cout << "Multiplication Table:" << endl;
// Your code goes here, with a loop for the rows, and inside of that
// a loop for the columns within that row.
//...
}//end allRowsAndColumns()
/*------------------------------------------------------------
Use a loop within a loop to display a subset from a
multiplication table, showing only some rows and columns.
Sample output:
Lab 4: Using loops
1. Show single row
2. Show multiplication table
3. Show a subset of a multiplication table
4. Exit the program.
Your choice (1-4)-->3
Enter the row start and limit, and the col start and limit: 2458
Multiplication Table for rows 2 to 4 and columns 5 to 8
10121416
15182124
20242832
Done.
*/
void selectRowsAndColumns(int rowStart, int rowLimit, int colStart, int colLimit)
{
cout << "Multiplication Table for "
<< "rows "<< rowStart <<" to "<< rowLimit <<" and "
<< "columns "<< colStart <<" to "<< colLimit
<< endl;
// Your code goes here
//...
}//end selectRowsAndColumns()
/*------------------------------------------------------------
Display menu options and jump to the corresponding code.
*/
int main()
{
// Declare variables to use in displaying all or part of a table.
// These variables don't all get used in all the cases below.
int rowStart, rowLimit, colStart, colLimit, size;
// Initialize them all to 0
rowStart=rowLimit=colStart=colLimit=size=0;
// Used to handle the menu option
char menuChoice ='';
while(menuChoice !='4'){
cout <<"
"
<< "Lab 4: Using loops
"
<<"1. Show single row
"
<<"2. Show multiplication table
"
<<"3. Show a subset of a multiplication table
"
<<"4. Exit the program.
"
<< "Your choice (1-4)-->";
cin >> menuChoice;
cout << endl;
// Handle menu choice to exit the program
if( menuChoice =='4'){
cout << "Exiting"
<< endl;
}
else if( menuChoice =='1'){
// Show a single line up to some limit
cout << "Enter the limit for the line of numbers: ";
cin >> colLimit;
singleLine( colLimit);
}
else if( menuChoice =='2'){
cout << "Enter the size for the multiplication table: ";
cin >> size;
// Show all rows and columns in the multiplication table
allRowsAndColumns(size);
}
else if( menuChoice =='3'){
// Show just the selected subset of the multiplication table
cout << "Enter the row start and limit, and the col start and limit: ";
cin >> rowStart >> rowLimit >> colStart >> colLimit;
selectRowsAndColumns( rowStart, rowLimit, colStart, colLimit);
}
}
cout << "Done." << endl;
return 0;
}//end main()

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!