Question

***** help me solve all these if possible.... especially don't miss the circle one *** thanks...

***** help me solve all these if possible.... especially don't miss the circle one *** thanks

/// The following program displays a 9*9 matrix.

#include <iostream>

using namespace std;

int main()
{
const int SIZE = 9;
for (int row = 0; row < SIZE; i++)
{
for (int col = 0; col < SIZE; j++)
{
cout << "*";
}
cout << endl;
}

}
///
/// Step 1: Could you change size of the matrix to 3*10 or 10*3?
///
///
/// Step 2: Display a pattern like the following figure when SIZE is 9.
///
/// *
/// *   
/// *   
/// *   
/// *   
/// *   
/// *   
/// *   
/// *
///
/// Step 3: Display a pattern like the following figure when SIZE is 9.
///
/// *********
/// ********
/// *******
/// ******
/// *****
/// ****
/// ***
/// **
/// *
///
/// Step 4: Display a pattern like the following figure when SIZE is 9.
///
///
/// *
/// **
/// ***
/// ****
/// *****
/// ******
/// *******
/// ********
/// *********
///
/// Step 5: Display a pattern like the following figure when SIZE is 9.
///
/// *********
/// *******
/// *****
/// ***
/// *
/// ***
/// *****
/// *******
/// *********
///
/// Step 6: Display a pattern like the following figure when SIZE is 9.
///
/// *********
/// * *
/// * *
/// * *
/// * *
/// * *
/// * *
/// * *
/// *********
///
///
/// Step 7: Display a pattern like the following figure when SIZE is 9.
///   
/// *+*+*+*+*
/// *+*+*+*+*
/// *+*+*+*+*
/// *+*+*+*+*
/// *+*+*+*+*
/// *+*+*+*+*
/// *+*+*+*+*
/// *+*+*+*+*
/// *+*+*+*+*
///
///
/// Step 8: Display a pattern like the following figure in the case that the size is odd. That is,
/// the boundaries are drawn and there is a cross of single line in the middle. (The
/// following figure shows a case in which the size is 9.)
///
/// *********
/// * * *
/// * * *
/// * * *
/// *********
/// * * *
/// * * *
/// * * *
/// *********
///
/// In the case that the size is even, the display is like the following figure.
/// That is, the boundaries are drawn and there is a cross of double lines in the middle.(The
/// following figure shows a case in which the size is 10.)
///
/// **********
/// * ** *
/// * ** *
/// * ** *
/// **********
/// **********
/// * ** *
/// * ** *
/// * ** *
/// **********
///
///
/// Step 9: Display a pattern like the following figure when SIZE is 9.   
///
/// *-*-*-*-*
/// -*-*-*-*-
/// *-*-*-*-*
/// -*-*-*-*-
/// *-*-*-*-*
/// -*-*-*-*-
/// *-*-*-*-*
/// -*-*-*-*-
/// *-*-*-*-*
///
/// Step 10: Display a pattern like the following figure when SIZE is 9.
///
/// *********
/// * *
/// * ***** *
/// * * * *
/// * * * * *
/// * * * *
/// * ***** *
/// * *
/// *********
///
/// Step 10: Display a Spray pattern like the following figure when SIZE is 9.
/// Spray has shape of circle. Inside the boundry the dotts randomly appear.
/// You can refer to the Spray tool in Paint to know how Spary work.
///
/// ++++++++++++++++++
/// + * * +
/// + * * * ** +
/// + * ** * ** * +
/// + * * *** ** * * +
/// + * ** **** * +
/// + * * * **** +
/// + * * ** +
/// ++++++++++++++++++
///
/// The following program draws a circle with the provided radius. You may use
/// this as a base for completeing the Spray pattern.
///
#include <iostream>

using namespace std;

void drawCircle(float r)
{
float pr = 2; // pr is the aspected pixel ratio which is almost equal to 2
for (int i = -r; i <= r; i++) // loop for horizontal movement
{
for (int j = -r; j <= r; j++) // loop for vertical movement
{
float d = ((i*pr)/r)*((i*pr)/r) + (j/r)*(j/r); //multiplying the i variable with pr to equalize pixel-width with the height
if (d >0.95 && d<1.08) // approximation
{
cout << "*";
}
else
{
cout << " ";
}
}
cout << endl;
}
}


int main()
{
float r;
cout<< " Enter the Radius" <<endl;
cin>> r;
drawCircle(r);

return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:

#include <iostream>

using namespace std;

void drawCircle(float r)

{

int rep = r;

if(rep%2==0){

rep = -1;

}else{

rep = 0;

}

float pr = 2; // pr is the aspected pixel ratio which is almost equal to 2

for (int i = -r/2; i <= r/2; i++) // loop for horizontal movement

{

for (int j = 0; j <= r; j++) // loop for vertical movement

{

float d = ((i*pr)/r)*((i*pr)/r) + (j/r)*(j/r); //multiplying the i variable with pr to equalize pixel-width with the height

if (d<1.08) // approximation

{

cout << "*";

}

else

{

cout << " ";

}

}

cout << endl;

}

}

void step1(){

cout<<"STEP 1"<<endl;

for (int i = 0; i < 3; i++)

{

for (int j = 0; j < 10; j++)

{

cout << "*";

}

cout << endl;

}

cout<<endl;

cout<<endl;

}

void step2(){

cout<<"STEP 2"<<endl;

const int SIZE = 9;

for (int i = 0; i < SIZE; i++)

{

cout << "*";

cout << endl;

}

cout<<endl;

}

void step3(){

cout<<"STEP 3"<<endl;

const int SIZE = 9;

for (int i = 0; i < SIZE; i++)

{

for (int j = i; j < SIZE; j++)

{

cout << "*";

}

cout<<endl;

}

cout<<endl;

}

void step4(){

cout<<"STEP 4"<<endl;

const int SIZE = 9;

for (int i = 0; i < SIZE; i++)

{

for (int j = 0; j < i+1; j++)

{

cout << "*";

}

cout<<endl;

}

cout<<endl;

}

void step5(){

cout<<"STEP 5"<<endl;

const int SIZE = 9;

for (int i = 0; i < SIZE; i++)

{

if(i<=SIZE/2){

for (int j = 2*i; j < SIZE; j++)

{

cout << "*";

}

}else{

for (int j = SIZE/2; j < 2*i+1-SIZE/2; j++)

{

cout << "*";

}

}

cout<<endl;

}

cout<<endl;

}

void step6(){

cout<<"STEP 6"<<endl;

const int SIZE = 9;

for (int i = 0; i < SIZE; i++)

{

if(i==0 || i==SIZE-1)

for (int j = 0; j < SIZE; j++)

{

cout << "*";

}

else

cout<<"**";

cout<<endl;

}

cout<<endl;

}

void step7(){

cout<<"STEP 7"<<endl;

const int SIZE = 9;

for (int i = 0; i < SIZE; i++)

{

for (int j = 0; j < SIZE; j++)

{

if(j%2==0)

cout << "*";

else

cout<<"+";

}

cout<<endl;

}

cout<<endl;

}

void stepSpray10(){

cout<<"STEP 10 Spray"<<endl;

const int SIZE = 9;

int rep = SIZE;

if(rep%2==0){

rep = -1;

}else{

rep = 0;

}

float r = SIZE;

float pr = 2; // pr is the aspected pixel ratio which is almost equal to 2

for(int i=0;i<SIZE*1.5;i++)

cout<<"+";

cout<<endl;

for (int i = -r/2; i <= r/2; i++) // loop for horizontal movement

{

bool star = 1;

for (int j = 0; j <= r; j++) // loop for vertical movement

{

if(j==0)

cout<<"+";

float d = ((i*pr)/r)*((i*pr)/r) + (j/r)*(j/r); //multiplying the i variable with pr to equalize pixel-width with the height

if (d<1.08) // approximation

{

cout << "*";

}

else

{

if(star==1){

cout<<"+";

star=0;

}else

cout << " ";

}

}

cout << endl;

}

for(int i=0;i<SIZE*1.5;i++)

cout<<"+";

cout<<endl;

cout<<endl;

}

int main()

{

step1();

step2();

step3();

step4();

step5();

step6();

step7();

stepSpray10();

return 0;

}

AS due to lack of time able to provide till 1 to 7 and last.

모 Console X <terminated> CPP Workspace.exe [C/ STEP 1 A STEP 2 varia STEP 3 kxxxkkkx* kxx*kx** kxx k x STEP 4 k x kxx kxx*kx** kxxxkkkx* STEP 5 kxxxkkkx* Smart Insert 170:29

Add a comment
Know the answer?
Add Answer to:
***** help me solve all these if possible.... especially don't miss the circle one *** thanks...
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
  • Subject: Object Oriented Programming (OOP) Please kindly solve the above two questions as soon as possible...

    Subject: Object Oriented Programming (OOP) Please kindly solve the above two questions as soon as possible would be really grateful to a quick solution. would give a thumbs up. Thank you! Q3: Question # 3 [20] Will the following code compile? If it does not, state the errors. If it does compile, write the output. //Function.cpp #include <iostream> using namespace std; void printData (long i) cout<<"In long print Data "«<i<<endl; } void printData(int i) cout<<"In int printData "<<i<<endl; ) void...

  • Can I get help with adding the following to this code please? 1. When buying multiple...

    Can I get help with adding the following to this code please? 1. When buying multiple tickets, if one of the seats selected is already taken, give a message like "Sorry, one or more of the seats selected is already taken." and prompt the user to select the seats all over. (Or if possible to make it suggest a location where the seats are together that the user can select instead) 2. Print the total cost after all of the...

  • This program is in C++ which reserves flight seats. It uses a file imported to get...

    This program is in C++ which reserves flight seats. It uses a file imported to get the seat chart called "chartIn.txt" which looks like this 1 A B C D E F 2 A B C D E F It continues until row 10. Sorry unable to provide the chartIn.txt file. I am having issues with function displaySeats, it displays then but when it comes to 10 the row looks like this 1 0 A B C D E ,...

  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

  • Can somebody help me with this coding the program allow 2 players play tic Tac Toe....

    Can somebody help me with this coding the program allow 2 players play tic Tac Toe. however, mine does not take a turn. after player 1 input the tow and column the program eliminated. I want this program run until find a winner. also can somebody add function 1 player vs computer mode as well? Thanks! >>>>>>>>>>>>>Main program >>>>>>>>>>>>>>>>>>>>>>> #include "myheader.h" int main() { const int NUM_ROWS = 3; const int NUM_COLS = 3; // Variables bool again; bool won;...

  • Id: 40100885 in c++ output text please thanks! what is the output values printed by the...

    Id: 40100885 in c++ output text please thanks! what is the output values printed by the following code? You need to explain step by step how each printed value is calculated. #include <iostream> using namespace std; int m = 0; void SampleMethod (int); int SampleMethod(); void increase(); int main() { int j = 9; SampleMethod(j); cout << j<<endl; return 0; w Y == void SampleMethod(int i) { if (j%2 1) cout << SampleMethod() <<endl; else cout << j << "...

  • Help me solve this in C++ Rewrite the code to use array instead of linked lists....

    Help me solve this in C++ Rewrite the code to use array instead of linked lists. Please do not change anything besides the data structure. Instead of linked list use an array. The functionality should remain exactly the same. You can prepare a class if you wish but it is not required. /** * Queue implementation using linked list C style implementation ( no OOP). */ #include <cstdio> #include <cstdlib> #include <climits> #include <iostream> #define CAPACITY 100 // Queue max...

  • I need help fixing this code and adding a loop please. Here is the original problem: #include <iostream> using namespace std; //function to print seating chart void printSeatingChart(int **cha...

    I need help fixing this code and adding a loop please. Here is the original problem: #include <iostream> using namespace std; //function to print seating chart void printSeatingChart(int **chart) {    int i, j;    cout << "\nROW\t";    for (i = 1; i <= 10; i++)    {        cout << i << "\t";    }    cout << "\n-----------------------------------------------------------------------------------\n";    for (i = 8; i >= 0; i--)    {        cout << "\n" << i + 1 << "\t";        for (j = 0; j < 10; j++)       ...

  • I need to update this C++ code according to these instructions. The team name should be...

    I need to update this C++ code according to these instructions. The team name should be "Scooterbacks". I appreciate any help! Here is my code: #include <iostream> #include <string> #include <fstream> using namespace std; void menu(); int loadFile(string file,string names[],int jNo[],string pos[],int scores[]); string lowestScorer(string names[],int scores[],int size); string highestScorer(string names[],int scores[],int size); void searchByName(string names[],int jNo[],string pos[],int scores[],int size); int totalPoints(int scores[],int size); void sortByName(string names[],int jNo[],string pos[],int scores[],int size); void displayToScreen(string names[],int jNo[],string pos[],int scores[],int size); void writeToFile(string...

  • Hello I need help fixing some things so that the C++ code follows all the requirements...

    Hello I need help fixing some things so that the C++ code follows all the requirements listed below. Thanks, This needed to fix: Rule 3 (Not Satisfied): In rule 3 it is asked to use conditional statements only for the base-case and for all other conditional expressions you must use ternary operators. You have used "if", "else" statements multiple times so this rule was not satisfied. Rule 6 (Not Satisfied): As per this rule you are permitted to use upto...

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