1 answer

Input a number [1-50] representing the size of the shape and then a character [x,b,f] which...

Question:

Input a number [1-50] representing the size of the shape and then a character [x,b,f] which represents the shape i.e. x->cros

Input a number [1-50] representing the size of the shape and then a character [x,b,f] which represents the shape i.e. x->cross, b->backward slash, or f->forward slash. Here are 4 examples which give the 2, inputs with the shape of the result directly below. Note: Even number outputs are different from odd. Prompt the user with the following cout<<"Create a numbered shape that can be sized."<<endl; cout<<"Input an integer number [1,50] and a character [x,b,f]."<<endl; Read in only 2 values such as Inputs 5 x 4 x 5 b 4f جم Based on the pair of inputs from above will produce the following Outputs 5 1 1 4 5 4 2 234 3 3 23 4.2 1 4 5 1 م م Now

Answers

pattern.cpp

#include<iostream>

using namespace std;

void printCross(int n)

{

int i,j,k;

if(n%2) //odd number of lines

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==i || j==(n-i+1))

cout<<j;

else

cout<<" ";

}

cout<<"\n";

}

}

else //even number of lines

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==i || j==(n-i+1))

{

cout<<" "<<j<<" ";

}

else

cout<<" ";

}

cout<<"\n";

}

}

}

void printForwardSlash(int n)

{

if(n%2)

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==n-i+1)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

else

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==(n-i+1))

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

}

void printBackwardSlash(int n)

{

if(n%2) // odd number of lines

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==i)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

else //even number of lines

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==i)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

}

int main()

{

int num;

char ch;

cout<<"Create a numberes shape that can be sized."<<endl;

cout<<"Input an integer [1,50] and a character [x,b,f]."<<endl;

cin>>num>>ch;

if(ch=='x' || ch=='X')

printCross(num);

else if(ch=='f' || ch=='F')

printForwardSlash(num);

else if(ch=='b' || ch=='B')

printBackwardSlash(num);

else

cout<<"\nWrong input"<<endl;

return 0;

}

OUTPUT

- 5 X TE: HOMEWORK\pattern.exe Create a numberes shape that can be sized. Input an integer (1,50) and a character [x,b,f]. 20- 5 X TE: HOMEWORK\pattern.exe Create a numberes shape that can be sized. Input an integer (1,50] and a character [x,b,f]. 10- 5 X TE: HOMEWORK\pattern.exe Create a numberes shape that can be sized.</p><p>Input an integer (1,50] and a character [x,b,f]. 13

.

Similar Solved Questions

1 answer
Baxter International Inc. can obtain funds for future investments through retained earnings, new issues of common...
Baxter International Inc. can obtain funds for future investments through retained earnings, new issues of common stock, and issuance of debt. Baxter's stock currently sells for $18 per share, paid a dividend of $1.20 last year (D0=$1.20), has a growth rate of 6% that is expected to continue, an...
1 answer
There are two tanks which are volume of first tank is 200gal and second one is...
there are two tanks which are volume of first tank is 200gal and second one is 100gal. concentraion of first on is 0.4lb/gal and second one is 0.2lb/gal. 4GPM of pure water is coming into first tank and it is perfect mixing. 4GPM of perfect mixed water is going out to second tank and mixed then goin...
1 answer
Tahoe Tent Ltd. issued bonds with a par value of $809,000 on January 1, 2017. The...
Tahoe Tent Ltd. issued bonds with a par value of $809,000 on January 1, 2017. The annual contract rate on the bonds was 16.50%, and the interest is paid semiannually. The bonds mature after three years. The annual market interest rate at the date of issuance was 14.50%, and the bonds were sold for $...
1 answer
Make the journal entry Exercise 16-9 Cash flows from financing activities Use the following information to...
Make the journal entry Exercise 16-9 Cash flows from financing activities Use the following information to determine cash flows from financing activities. a. Net income was $35,000. b. Issued common stock for $64,000 cash. c. Paid cash dividend of $14,600. d. Paid $50,000 cash to settle a note payab...
1 answer
It took 3 people 5 hours to build a garden wall. another garden wall is to be built. the new wall is the same length but twice the height as the first wall. how long will it take 5 people to build the new wall?
It took 3 people 5 hours to build a garden wall. another garden wall is to be built. the new wall is the same length but twice the height as the first wall. how long will it take 5 people to build the new wall?...
1 answer
. «A scendence intervaluates to 4135 to 60 find them Determine the same r ead is...
. «A scendence intervaluates to 4135 to 60 find them Determine the same r ead is conter to have...
1 answer
6. Fill in the blanks: (7 marks) A. The reaction between a Hemiacetal carbon and an...
6. Fill in the blanks: (7 marks) A. The reaction between a Hemiacetal carbon and an alcohol produces ain), B. A sugar ester is an intermediate in pathway. C. In a branched chain polysaccharide (Glycogen), all the glycosidic bonds along the chain are and those at the branch point are linkages. D. B. ...
1 answer
For each of these addressing modes Indexed register For each Provide a motivated context in C...
For each of these addressing modes Indexed register For each Provide a motivated context in C well suited to its use. (hint: think about variable lifetime) Indicate whether the encoding of this addressing mode requires an extension word, and why....
1 answer
How do you factor #x^6(y^2-1) - x^3(y^2-1)#?
How do you factor #x^6(y^2-1) - x^3(y^2-1)#?...
1 answer
Charlene is the owner of Charlene's Computer Care (3C) and has been in the business of...
Charlene is the owner of Charlene's Computer Care (3C) and has been in the business of servicing computers and computer systems at affordable prices for just over five years. 3C's primary clients are local businesses but include some residential customers. Their advertised approach is to ana...
1 answer
I need one example for each one .. The homework is about finding examples .. 1....
I need one example for each one .. The homework is about finding examples .. 1. Prevent waste 2. Atom Economy 3. Less Hazardous Synthesis 4. Design Benign Chemicals 5. Benign Solvents & Auxiliaries 6. Design for Energy Efficiency 7. Use of Renewable Feedstocks 8. Reduce Derivatives 9. Cataly...
1 answer
(3x, The joint density function of X and Y is given by 0 Sy sxs1 f(x,...
(3x, The joint density function of X and Y is given by 0 Sy sxs1 f(x, y) = 0, otherwise. a) Use the distribution function technique to find the distribution function of W = X-Y. For 50% of the points, you may use the transformation technique, which is longer. >) Find the probability density funct...
1 answer
Need to find a article from WSJ must come from articles published between June 24, 2019...
Need to find a article from WSJ must come from articles published between June 24, 2019 and July 22, 2019 and must cover topics related to Corporate-level strategy, International strategy, Strategic control and corporate governance, Organizational designs, Strategic leadership, and Managing innovati...
1 answer
Price (S) 50 Quantity Figure 3 12. Refer to Figure 3. Assume that production of this good generates a $30 per unit exte...
Price (S) 50 Quantity Figure 3 12. Refer to Figure 3. Assume that production of this good generates a $30 per unit external cost. How many of the following regulations would lead to the efficient outcome? • A price ceiling at $30 • A price floor at $60 • A per-unit tax of $30 • A...
1 answer
I have created this java program but need help by making it the userHours limited to...
i have created this java program but need help by making it the userHours limited to only 0 to 720 for all packages. If any number higher than 720, get this display Invalid input, please enter number of hours between 0 & 720.   Let’s try again.   Enter the customer'...