Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to \"draw\" ellipses by printing characters, to the followin

ID: 3646708 • Letter: W

Question

Write a C++ program to "draw" ellipses by printing characters, to the following specifications:

Prompt the user for values for a and b, then draw an ellipse using the formula
(x2/a2)+(y2/b2)=1. Actually, since double values in C++ are rarely exact, use (x2/a2)+(y2/b2)-1.0<0.0001, but use a named constant in place of 0.0001.
Since there are 25 rows in a standard PuTTy screen, output 24 rows for the ellipse. For each row number row 0 to 23, let y be 12-row.
Since there are 80 columns in a standard PuTTy screen, output 80 characters in each line. Since each column is equivalent to about half a row in terms of space, for each column number col 0 to 79, let x be (40-col)/2.
Use pow from <cmath> to calculate the squares, ensuring that the two parameters are of type double.
After the ellipse, output information about it and prompt to repeat or not.
If it is a circle, output the word Circle, the radius of the circle (either a or b), the area of the circle and the number of characters printed in the "drawing", as in the first example.
If it is not a circle, output the word Ellipse, both a and b, the area of the ellips and the number of characters printed, as in the second example.
The area of an ellipse is ? * a * b. Use M_PI from <cmath> for the value of ?.
All floating point numbers should be output in fixed format, always showing the point and with a precision of 2 places after the point.

Every variable must have a comment explaining briefly what it is for.

Explanation / Answer

01 #include 02 #include 03 using namespace std; 04 const double PI = M_PI; 05 const double ZERO = 0.0001; 06 int a, b; //variables for a and b 07 int characters; //variable for the number of characters used to create the shape 08 09 int main(){ //main method that uses a do-while loop to repeat the program if the user enters anything besides Y or y at the end. 10 char continue; //variable for repeating the program after it has been run 11 do{ runProgram() 12 cout > continue; 14 } 15 while((continue!='n')||(continue!='N')) 16 } 17 18 int runProgram(){ //gets input from the user and, draws the ellipse, and outputs information about the ellipse 19 cout > a >> endl;//inputs number from keyboard to variable a 21 cout > b >> endl;//inputs number from keyboard to variable b 23 // drawEllipse(); //method to draw ellipse 24 circletest(); //method to output information about the ellipse 25 characters(); //method to output the number of characters that the ellipse used 26 } 27 28 int drawEllipse(){ //method to draw an ellipse based off of the variables 'a' and 'b' that the user inputted in the runProgram method. 29 int y=0,x=0;row=0 30 for(y=0; y
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote