1st post definitely not my last.

Hello all, I am in need of some assistance with my CS homework, its week 1 into the class and we are asked to create shapes out of asterisk. i successfully coded the first shape but I need a little help starting the other 2 shapes. Now i am not asking for the codes for the second and third figures to be coded for me, i just need help starting them. ( dashes are also printed out.)

the instructions are as followed:

Write a program to
1. Request that the user enter a positive odd number less than 40.
2. If the user enters a positive odd number less than 40, print "Thank you", and continue to 5.
3. Repeat that request up to 3 time if the user enters an incorrect number.
4. If the user fails to enter a correct number , by the third try:
a. Write a polite message explaining what criteria (positve, odd, less than forty) they missed.
b. Write a polite messages telling the user to try again later and exit.
5. Print the three figures below each with the given size and exit


The following illustrate how the program might run"

Please enter a positive odd number < 40 for the size of the figures: 10
Please enter a positive odd number < 40 for the size of the figures: 11
Thanks you


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  #include <iostream>
using namespace std;

int main()
{
    int size;
    cout << "enter size:";
    cin >> size;
    
    
    if (size%2 ==1)
    {
        cout << "thank you" << endl;
        for (int i = 0; i < size; ++i)
            
        {
            for (int j = 0; j < size-1; ++j)
            {
                if (i == 0 || i == size-1)
                {
                    cout << "--";
                }
                else
                {
                    cout << "* ";
                }
                
                
            }
            
            if (i == size-1)
            {
                cout << "--";
            }
            else if (i !=0)
            {
                cout << "*|";
            }
            else
            {
                cout << "--";
            }
            
            cout << endl;
        }
        return 0;
    }
    
    }


------------------------
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
* * * * * * * * * * *|
-------------------------

Figure 2 prints out a sideways hourglass, and Figure 3 prints out an hour glass.
Last edited on
Topic archived. No new replies allowed.