Ok my project is to make several shapes that are all controlled by the user as far as what size and character is used I have the parallelogram, rectangle, triangles and the even diamond. But I cant get the odd diamond. I can only use the libraries that are in the code no arrays just selection, sequence and repetition. Spent probably around 24 hrs on the diamond one but am just running in circles any help would be greatly appreciated. I know its ugly but I'm taking an online course through a community college and my teacher is pretty much useless he gives hints but no firm concrete help. The odd diamond is just like the even but ends with only one character. Has the number of characters across that is input by user and reduces by 2 up and down ending in a single character.

//**************************************************************************************
// Programmer: Justin Harvey                     CSC Programming Assignment Selection
// Description:
//
//
// Input:
// Output:
//
//
//
//**********************************************************************************************/

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main ()
   {
   char letter;
   char input;
   int width;
   int lines;
   int row;
   int col;
   int spaces;
    do
    {			
			cout << "Enter a letter from A to E, F exits the program \n"; 
			cout << " Your choice? ";
			cin >> letter ;
		
		if (letter == 'f' || letter == 'F' )
		      break;
			
	    if ( letter > 'f' || (letter > 'F' && letter <= 96 ))
		     
			 cout << " I am sorry you have entered an invalid response.\n\n";			
			
		if (letter == 'a' || letter == 'A')
        {   
			cout << "Enter a Character: ";
			cin  >> input;
			
			cout << "Number of Lines: ";
			cin  >> lines;
			cout << "Number of Characters per line: ";
			cin  >> width;
			
			for ( row =1 ; row <= lines ; row ++)
			{
			   for ( col = 1 ; col <= width ; col ++)
			   { 
			       cout << input;
			   }
				cout << "\n";
			}
        }
		else if(letter == 'b' || letter == 'B')
		{
			cout << "Enter a Character: ";
			cin  >> input;
			
			cout << "Number of lines: ";
			cin  >> lines;
			
			for ( row =1 ; row <= lines ; row++)
			{
			   for ( col = 1 ; col <= row ; col++)
			   {
			       cout << input;
			   }
				cout << "\n";
			}
						
		}	
		else if (letter == 'c' || letter == 'C')
		{
			cout << "Enter a Character: ";
			cin  >> input;
			
		    cout << "Number of lines: ";
			cin  >> lines;
			
			for ( row =lines ; row >= 1 ; row--)
			{
			   for ( col =2*row ; col >=2 ; col = col-2)
			   {
			       cout << input << input;
				  
			   }
				cout << "\n";
			}

		}
		else if ( letter == 'd' || letter == 'D')
		{
			cout << "Enter a Character: ";
			cin  >> input;
			
		    cout << "Height of Parallelogram: ";
			cin  >> lines;
			
			for ( row =1 ; row <= lines ; row ++)
			{
			   for (col = 2; col <= lines*2 ; col = col + 2)
			   {
			        if( col <= lines*2 - row*2)
						cout << "  ";
				    else
						cout << input << input;
			   }
				cout << "\n";
			}
			for ( row = lines-1 ; row >= 1; row--)
			{
			    for ( col = 2 * row ; col >= 2 ; col = col - 2)
			    {
				   cout << input << input;
			    }
				cout << "\n";
			}
		}
		
		else if (letter == 'e' || letter == 'E')
		{
			cout << "Enter a Character: ";
			cin  >> input;
		 
			cout<< "Maximum characters per line? ";
			cin >> lines;
			
			
			
			 if (lines % 2 == 0)
			 		
			{
			     for ( row =0 ; row <= lines/2 ; row ++)
			    {
					for (col = 1; col <= lines/2 ; col++)
					{
						if( col <= lines/2 - row)
							cout << " ";
						else
							cout << input<<input ;
				     }
				     cout << "\n";
				}
				
				for (row = lines/2 - 1; row>=0 ; row--)
				{
			        for(col=1; col <= lines/2; col++)
					{ 
					 
					    if ( col <= lines/2 - row)
						      cout << " ";
					    else
					       cout << input<<input;
					}
					cout<< "\n";	
				}	
			}

	
			 if (lines % 2 == 1 )
			{
				for ( row =0 ; row <= lines/2 ; row ++)
			    {
					for (col = 1; col <= lines/2 ; col++)
					{
						if( col <= lines/2 - row)
							cout << " ";
						else
							cout << input<<input ;
				     }
				     cout << "\n";
				}
				
				for (row = lines/2 - 1; row>=1 ; row--)
				{
			        for(col=1; col <= lines/2; col++)
					{ 
					 
					    if ( col <= lines/2 - row)
						      cout << " ";
					    else
					       cout << input<<input;
					}
					cout<< "\n";
				}	
				
			}	
		}
		
		 
	}
	while (letter != 'F' || letter !='f');
	return 0;
	}

Edited 6 Years Ago by cpt clueless: n/a

Attachments
//******************************************************************************************
// Programmer: Justin Harvey                     CSC Programming Assignment Selection
// Description:
//
//
// Input:
// Output:
//
//
//
//**********************************************************************************************/

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main ()
   {
   char letter;
   char input;
   int width;
   int lines;
   int row;
   int col;
   int spaces;
    do
    {			
			cout << "Enter a letter from A to E, F exits the program \n"; 
			cout << " Your choice? ";
			cin >> letter ;
		
		if (letter == 'f' || letter == 'F' )
		      break;
			
	    if ( letter > 'f' || (letter > 'F' && letter <= 96 ))
		     
			 cout << " I am sorry you have entered an invalid response.\n\n";			
			
		if (letter == 'a' || letter == 'A')
        {   
			cout << "Enter a Character: ";
			cin  >> input;
			
			cout << "Number of Lines: ";
			cin  >> lines;
			cout << "Number of Characters per line: ";
			cin  >> width;
			
			for ( row =1 ; row <= lines ; row ++)
			{
			   for ( col = 1 ; col <= width ; col ++)
			   { 
			       cout << input;
			   }
				cout << "\n";
			}
        }
		else if(letter == 'b' || letter == 'B')
		{
			cout << "Enter a Character: ";
			cin  >> input;
			
			cout << "Number of lines: ";
			cin  >> lines;
			
			for ( row =1 ; row <= lines ; row++)
			{
			   for ( col = 1 ; col <= row ; col++)
			   {
			       cout << input;
			   }
				cout << "\n";
			}
						
		}	
		else if (letter == 'c' || letter == 'C')
		{
			cout << "Enter a Character: ";
			cin  >> input;
			
		    cout << "Number of lines: ";
			cin  >> lines;
			
			for ( row =lines ; row >= 1 ; row--)
			{
			   for ( col =2*row ; col >=2 ; col = col-2)
			   {
			       cout << input << input;
				  
			   }
				cout << "\n";
			}

		}
		else if ( letter == 'd' || letter == 'D')
		{
			cout << "Enter a Character: ";
			cin  >> input;
			
		    cout << "Height of Parallelogram: ";
			cin  >> lines;
			
			for ( row =1 ; row <= lines ; row ++)
			{
			   for (col = 2; col <= lines*2 ; col = col + 2)
			   {
			        if( col <= lines*2 - row*2)
						cout << "  ";
				    else
						cout << input << input;
			   }
				cout << "\n";
			}
			for ( row = lines-1 ; row >= 1; row--)
			{
			    for ( col = 2 * row ; col >= 2 ; col = col - 2)
			    {
				   cout << input << input;
			    }
				cout << "\n";
			}
		}
		
		else if (letter == 'e' || letter == 'E')
		{
			cout << "Enter a Character: ";
			cin  >> input;
		 
			cout<< "Maximum characters per line? ";
			cin >> lines;
			
			
			
			 if (lines % 2 == 0)
			 		
			{
			     for ( row =0 ; row <= lines/2 ; row ++)
			    {
					for (col = 1; col <= lines/2 ; col++)
					{
						if( col <= lines/2 - row)
							cout << " ";
						else
							cout << input<<input ;
				     }
				     cout << "\n";
				}
				
				for (row = lines/2 - 1; row>=0 ; row--)
				{
			        for(col=1; col <= lines/2; col++)
					{ 
					 
					    if ( col <= lines/2 - row)
						      cout << " ";
					    else
					       cout << input<<input;
					}
					cout<< "\n";	
				}	
			}

	
			 if (lines % 2 == 1 )
			{
				for ( row =0 ; row <= lines/2 ; row ++)
			    {
					for (col = 1; col <= lines/2 ; col++)
					{
						if( col <= lines/2 - row)
							cout << " ";
						else
							cout << input<<input ;
				     }
				     cout << "\n";
				}
				
				for (row = lines/2 - 1; row>=1 ; row--)
				{
			        for(col=1; col <= lines/2; col++)
					{ 
					 
					    if ( col <= lines/2 - row)
						      cout << " ";
					    else
					       cout << input<<input;
					}
					cout<< "\n";
				}	
				
			}	
		}
		
		 
	}
	while (letter != 'F' || letter !='f');
	return 0;
	}

I asked it in the first post but I can't get the diamond for odd #'s to work it's already submitted wrong but I want to figure it out. I ran in circles with this stuff so much that I don't even know how I got them to work. But they did which really doesn't help me. Anyone want to explain what I did and what makes it work. How do I replicate it? Also if we could fix my odd diamond too so I can maybe see what I needed to do. Also can only use repetition, sequence and selection.

This article has been dead for over six months. Start a new discussion instead.