Question

In: Computer Science

I am having a difficult time with this loop. Needs to be in C++. Given numRows...

I am having a difficult time with this loop. Needs to be in C++.

Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numColumns = 3 prints:

1A 1B 1C 2A 2B 2C 

#include <iostream>
using namespace std;

int main() {
int numRows;
int numColumns;
int currentRow;
int currentColumn;
char currentColumnLetter;

cin >> numRows;
cin >> numColumns;

/* Your solution goes here */

cout << endl;

return 0;
}

Solutions

Expert Solution

Please find below code as per your requirement.

Thank you.

#include <iostream>
using namespace std;
int main()
{
int numRows;
   int numColumns;
   int currentRow;
   int currentColumn;
   char currentColumnLetter;

cout <<" Enter Row number :";
cin >> numRows;

cout << " Enter Column number :";
cin >> numColumns;
  
   for (int i = 0;i<numRows;i++)//Number of rows loop
   {
       currentColumnLetter = 'A';
       for (int j = 0; j<numColumns;j++)//Number of columns loop
       {
cout << (i + 1) << currentColumnLetter << " ";//Print Seat number
           currentColumnLetter++;//Gets next character
       }
cout << " ";//For new row
   }
   return 0;
}

Output

Enter Row number :2 Enter Column number :3 LA 1B 10 2A 2B 2C C: Sample ProjectsCPlusPlusFirstConsoleApplicationDebugCPlusPlusFirstConsoleApplication.exe (process 19132) exited w th code e.


Related Solutions

Hi! I am having a difficult time thinking of a topic for my research paper if...
Hi! I am having a difficult time thinking of a topic for my research paper if anyone is able to help out that would be appreciated! One challenge is defining a specific topic. For example, the topic "Federal Reserve" is far too broad. Here are considerations and suggestions for you in defining your research topic: 1. Start by review the major topics of the course. See how the textbook is organized, and flip through the various chapters to identify potential...
Using the BAII Plus calculator I am having a difficult time using this calculator to solve...
Using the BAII Plus calculator I am having a difficult time using this calculator to solve this MIRR 0 =-325,000 1=50,000 2= 75,000 3=-60,000 4=225,000 5=300,000 Required rate of return =15% We discount all negative CFs(at 15%) time 0 We compound all positive cash flows (at 15%) to 5 years This is now the TV or Terminal Value Please help me understand how to calculate these numbers?
This needs to be done in Excel and that is where I am having issues Healthy...
This needs to be done in Excel and that is where I am having issues Healthy Snacks Co. produces snack mixes. Recently, the company has decided to introduce a new snack mix that has peanuts, raisins, pretzels, dries cranberries, sunflower seeds and pistachios. Each bag of the new snack is designed in order to hold 250 grams of the snack. The company has decided to market the new product with a emphasis on its health benefits. After consulting nutritionists, Healthy...
C# programming. Comment/Explain the below code line by line. I am having a hard time following...
C# programming. Comment/Explain the below code line by line. I am having a hard time following it. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Nth_prime {     class Program     {         public static bool isPrime(int number)         {             int counter = 0;             for (int j = 2; j < number; j++)             {                 if (number % j == 0)                 {                     counter = 1;                     break;                 }             }             if (counter == 0)             {                 return true;             }             else             {                 return false;             }         }...
I am having an issue with the code. The issue I am having removing the part...
I am having an issue with the code. The issue I am having removing the part when it asks the tuter if he would like to do teach more. I want the program to stop when the tuter reaches 40 hours. I believe the issue I am having is coming from the driver. Source Code: Person .java File: public abstract class Person { private String name; /** * Constructor * @param name */ public Person(String name) { super(); this.name =...
I understand the answer to this I am just having a hard time creating a graph...
I understand the answer to this I am just having a hard time creating a graph for it. Bill the butcher is upset because the government plans to tax beef $.10 a pound. "I hate paying taxes," he says. "Because of this, I'm raising all my beef prices by $.10 a pound. The consumers will bear this burden, not me." Do you see anything wrong with this way of thinking? Explain. Draw a graph describing your answer and attach it...
I am having trouble with a C++ code that I'm working on. It is a spell...
I am having trouble with a C++ code that I'm working on. It is a spell checker program. It needs to compare two arrays, a dictionary, and an array with misspelled strings that are compared to the strings in the dictionary. the strings that are in the second array that is not in the Dictionary are assumed to be misspelled. All of the strings in the dictionary are lowercase without any extra characters so the strings that are passed into...
I am having a hard time getting started on how to do this assignment. I would...
I am having a hard time getting started on how to do this assignment. I would like some ideas on how to start the MEMO. and maybe some ideas on what you would include. But I don't necessarily need the assignment completed for me. just need ideas!!! One routine negative message in the form of an internal memo. 400-500 word message. Single-spaced, with 1-inch margins on all sides. Objective: To announce organizational restructuring, one routine negative message addressed to employees....
I have figured out this assignment, but I am having a hard time figuring out the...
I have figured out this assignment, but I am having a hard time figuring out the extra credit, Thanks! Creating a Rectangle class We have created a representation of a rectangle in C++ and extended it to create multiple representation's of rectangles. Classes can simplify that process considerably. In this assignment, your task is to convert the representation of a rectangle we created earlier in the semester to a Rectangle class. The Rectangle class shall consist of the following: The...
SOLVE IN C: Given numRows and numColumns, print a list of allseats in a theater....
SOLVE IN C: Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numColumns = 3 prints:1A 1B 1C 2A 2B 2C
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT