GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Sep-2006, 10:35
Mike Gustafson Mike Gustafson is offline
New Member
 
Join Date: Sep 2006
Posts: 24
Mike Gustafson is on a distinguished road

Menu driven drawing program


Hello again,

If I make it though this class it will be a miricle. Now I to do this and can't even get started text book not much help so here it goes, I really need help with this one.

Write a menu driven appication that displays the following menu and draws shapes. Your program should run continuosly until the users selects to quit the program. In addition to the following outputs, turn in the psuedocode and a flow chart of your program.
1.) Draw a Diamond
2.) Draw a Wine Glass
3.) Draw a Triangle
4.) Quit the program.
Am I wrong to think this is difficult if you have never programed what so ever and this is my first programming course.
Any help I will be very happy to get.
Thank you
  #2  
Old 02-Oct-2006, 13:22
Mike Gustafson Mike Gustafson is offline
New Member
 
Join Date: Sep 2006
Posts: 24
Mike Gustafson is on a distinguished road

Re: Menu driven drawing program


Can anyone please give me a hand with the above ^^^^^ I'm really in need of some help.
Thanks
  #3  
Old 03-Oct-2006, 14:24
Mike Gustafson Mike Gustafson is offline
New Member
 
Join Date: Sep 2006
Posts: 24
Mike Gustafson is on a distinguished road

Re: Menu driven drawing program


I finally got it does it look ok? I know a real programmer would do it much better and more simple but it works. Did I waste a lot of printf lines?

CPP / C++ / C Code:
/* Project 2
	Menu driven drawing program */


#include <stdio.h>

/* function main begins program execution */


int main() /* start program */
{
	int num; /* number of shape you want to draw */

	printf(" Enter a number to draw \n 1 Diamond\n 2 Wine Glass\n 3 Triangle\n 4 Quit\n ");
	scanf("%d",&num);
		if ( num <=3 ) /* a choosen shape will draw */
		{
			do 
			   
			{
				if (num == 1) /* a diamond will be drawn */
				{

					printf( "    *  \n");
					printf( "   ***  \n");
					printf( "  ***** \n");
					printf( " *******\n");
					printf( "*********\n");
					printf( " *******\n");
					printf( "  ***** \n");
					printf( "   ***  \n");
					printf( "    *  \n");
				}
	
						else 
								if (num == 2) /* a wine glass will be drawn */
								{			 
									printf("**********\n");
									printf( " *******\n");
									printf( "  ***** \n");
									printf( "   ***  \n");
									printf( "    *  \n");
									printf( "   ***  \n");
									printf( "  ***** \n");
									printf( " *******\n");

							    }
						else 
				                  if (num == 3) /* a triangle will be drawn */
							      {			 
									printf("***********\n");
									printf("**********\n");
									printf("*********\n");
									printf("*******\n");
									printf("******\n");
									printf("*****\n");
									printf("****\n");
									printf("***\n");
									printf("**\n");
									printf("*\n");
								  }

			printf(" Enter a number to draw \n 1 Diamond\n 2 Wine Glass\n 3 Triangle\n 4 Quit\n ");
			scanf("%d",&num);

			}while (num<=3); /* continue to draw shapes while number <=3 */
        
		} /* end if */
	
	return 0; /* indicate program ended successfully */

}		/* end function main */
Last edited by LuciWiz : 04-Oct-2006 at 00:23. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #4  
Old 03-Oct-2006, 15:00
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,373
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Menu driven drawing program


Quote:
Originally Posted by Mike Gustafson
I finally got it does it look ok? I know a real programmer would do it much better and more simple but it works. Did I waste a lot of printf lines?
Yes. Use loops.

And what part of
Last edited by admin. Reason: Please insert your C code between [cpp] & [/cpp] tags
is so hard to understand? Every post you make with code has to be modified. Maybe you need to review the Guidelines again.
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
  #5  
Old 05-Oct-2006, 16:13
Mike Gustafson Mike Gustafson is offline
New Member
 
Join Date: Sep 2006
Posts: 24
Mike Gustafson is on a distinguished road

Re: Menu driven drawing program


Quote:
Originally Posted by WaltP
Yes. Use loops.

And what part of
Last edited by admin. Reason: Please insert your C code between [cpp] & [/cpp] tags
is so hard to understand? Every post you make with code has to be modified. Maybe you need to review http://www.gidforums.com/t-5566.html again.

Yes I didn't post it right sorry. Well I did it all wrong loops like you say is the way I'm supposed to do it. This is sort of what I have to get the program to draw except shapes are different and bigger. I can't figure out how you make it loop to print ***********'s in a certain order and placement.

*******
****
**
*
  #6  
Old 05-Oct-2006, 23:40
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,373
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Menu driven drawing program


You have multiple lines. Therefore a loop is in order to go from line to line -- at least from top to line with the most *'s. There's loop #1.

Count the Spaces on the first line of your printf() attempt, then the second line. Is there a correlation between the numbers? Keep going for each line and compare each line for spaces. See a pattern? Loop #2 within loop #1 to print spaces.

Now do exactly the same for the *'s. Loop #3 within loop #1, but after loop #2 to print *'s.

There's your top triangle.

Use [code][/code] tags to display your pattern:
Code:
* *** ***** ********
And this info will help you with your formatting.
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
Pipeline freeze simulation darklightred C++ Forum 6 27-Jul-2006 19:37
Shapes Functions Version 2 - Arrays! Cecil C Programming Language 1 09-Jul-2006 20:39
Help with a complex program lordfuoco C++ Forum 5 24-Jun-2006 06:03
How to read particular memory location ? realnapster C Programming Language 10 10-May-2006 09:11

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:38.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.