Question

*PLEASE NO BOOL, CHAR, OR FOR STATEMENTS! Thanks! C++: Create a box based on user input....

*PLEASE NO BOOL, CHAR, OR FOR STATEMENTS! Thanks!

C++: Create a box based on user input.

For example: Enter the number of rows (max 99): 10

Enter the number of cols (max 99): 20

Enter an interior character: |

Enter an exterior character: +

+ + + + + + + + + + + + + + + + + + + +

+ | | | | | | | | | | | | | | | | | | +

+ | | | | | | | | | | | | | | | | | | +

+ | | | | | | | | | | | | | | | | | | +

+ | | | | | | | | | | | | | | | | | | +

+ | | | | | | | | | | | | | | | | | | +

+ | | | | | | | | | | | | | | | | | | +

+ | | | | | | | | | | | | | | | | | | +

+ | | | | | | | | | | | | | | | | | | +

+ + + + + + + + + + + + + + + + + + + +

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<cmath>
#include<iostream>
using namespace std;

int main() {
   int n, m;
   char ch1, ch2;
   cout<<"Enter the number of rows (max 99): ";
   cin>>n;
   cout<<"Enter the number of cols (max 99): ";
   cin>>m;
   cout<<"Enter an interior character: ";
   cin>>ch1;
   cout<<"Enter an exterior character: ";
   cin>>ch2;
   for(int i = 0;i<n;i++){
      for(int j = 0;j<m;j++){
         if(i == 0 || i==n-1 || j==0 || j==m-1){
            cout<<ch2;
         }
         else{
            cout<<ch1;
         }
      }
      cout<<endl;
   }
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
*PLEASE NO BOOL, CHAR, OR FOR STATEMENTS! Thanks! C++: Create a box based on user input....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a. Ask the user for the input of a letter (char type). Write a function that...

    a. Ask the user for the input of a letter (char type). Write a function that takes a char as the argument (parameter) and returns the ASCII value of that char back to the caller. Call the function using the char variable and taking input from the user (no validation required). Display the value in ASCII. b. Write a program that takes a char as the argument (parameter) and uses a loop to interrogate the char, calling a function that...

  • We use JAVA. Thanks.    Create an application whose main method asks the user to enter...

    We use JAVA. Thanks.    Create an application whose main method asks the user to enter an n by m integer matrix that contains nm integer numbers. n and m should be between 1 and 10. If the user enters a             number less than 1 or greater than 10, the program will continue to ask the user to enter an integer number between 1 and 10. The program should print the sum of the boundary elements of the matrix....

  • In C plus plus Objective: Create an array of numbers based upon user input. Program logic:...

    In C plus plus Objective: Create an array of numbers based upon user input. Program logic: Ask the user for how big to size the array. Create an array based upon that size. Ask for a number, add that number to the array. Repeat adding to the end until all numbers have been entered or until they enter -1 for the number. Print the list.

  • IN C++ Create a method called xChar that will replace a specified char in a String...

    IN C++ Create a method called xChar that will replace a specified char in a String with the 'X' character. Your function must use a pointer to search and replace the char. You are not allowed to use array notation to solve this problem. Your function should take as arguments in the CString to search through and a char variable that holds the char to be searched for and replaced. The function should also return the number of replacements made....

  • Step 2: Create the method specified below. static int GetValidWidth(string prompt) Input parameters prompt: message for...

    Step 2: Create the method specified below. static int GetValidWidth(string prompt) Input parameters prompt: message for user describing the input required Returns A non-zero width entered by the user Step 3: Create the method specified below. static int GetValidHeight(string prompt) Input parameters prompt: message for user describing the input required Returns A non-zero positive height entered by the user Step 4: Create the method specified below. static void DisplayBox(int width, int height, char fillChar) Input parameters width: width of each...

  • C++ there is an issue with my if/else statements, I have tried several different ways to...

    C++ there is an issue with my if/else statements, I have tried several different ways to make it match the instructions but each time i get different errors. Need help geting this to match the instructions peoperly. *******************instructions***************************** Function: nextGeneration This function has no parameters. This function returns an int. The purpose of this function is to modify the grid to represent the next generation. Here's how you are supposed to do that for this assignment: Set each element of...

  • Here is the (A3b-smallgrades.txt) text file: Here is the (A3b-largegrades.txt) text file: Here is the Program...

    Here is the (A3b-smallgrades.txt) text file: Here is the (A3b-largegrades.txt) text file: Here is the Program A3a without modification: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> void getGrades(int ROWS, int COLS, int grades[ROWS][COLS], char students[COLS][20]); void printGrades(int ROWS, int COLS, int grades[ROWS][COLS]); void getStudents(int COLS, char students[COLS][20]); void printStudents(int COLS, char students[COLS][20]); void calcGrades(int ROWS, int COLS, int grades[ROWS][COLS], char Fgrades[]); void printFinalGrades(int COLS, char Fgrades[]); int main() {    srand(time(0));    int stu = 0, assign = 0;...

  • In C programming language: This program will output a right triangle based on user specified height...

    In C programming language: This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or *....

  • I need to create a code for this prompt: In this project we will build a...

    I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...

  • Create a C# Form with a textbox and a button. The box is for a user...

    Create a C# Form with a textbox and a button. The box is for a user to enter a number of seconds. And when the user clicks the button, the program displays the equivalent number of hours, minutes and seconds using a MessageBox. Show method. If the seconds entered is less than 60, your program should only display the seconds; if the seconds is a least 60 and less than 3600, your program should display minutes and seconds; if the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT