My teacher for my online C++ class assigned an optional assignment. He said learning this may help on the test but he did not give any information on how to go about doing it. I watched some videos online and know how to make asterisks shapes but this is way over my head:
Write a program that
repeatedly asks the user to select either square, left or right triangle, then inputs the figure size and
then prints the appropriate shape in stars. For square, the program should ask whether the user wants a
filled or a hollow square. The program should quit if the user inputs an invalid option. See an example
dialog below:
1. square
2. left triangle
3. right triangle
select figure: 1
select size: 4
filled or hollow [f/h]: h
****
* *
* *
****
1. square
2. left triangle
3. right triangle
...
You can reuse your code from the Looping lab (assignment 3). Place the star-printing code in four separate
functions: filledSquare, hollowSquare, leftTriangle and rightTriangle. Each function should accept a single
integer parameter - the size of the figure and return no value (be a void-function). Place the triangle and
square function definitions below main function, and their prototypes above the main.
Here is what I have so far. I am do not really know what I am doing.
#include <iostream>
using std::cout; using std::cin; using std::endl;
int main(){
int shape, size, enterS;
char shapeType;
cout << "Select a shape by entering its number" << endl;
cout << "1. Square" << endl << "2. Left triangle" << endl << "3. Right triangle" << endl;
cin >> shape;
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.