ascii art

how to allign ascii art properly?

Page 1 of 1

4 Replies - 2761 Views - Last Post: 10 March 2009 - 10:34 AM Rate Topic: -----

#1 knight_t  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-March 09

ascii art

Posted 09 March 2009 - 01:39 PM

Hello all,im new to programming world and this is my assignment for computer procramming.
I got some problem here,my ascii arts are not allign properly when i run the program and there is some error in ascii art.Anyone can help me?
"I copy this directly from my dev c++"

#include<stdio.h>
#include<stdlib.h>

int main()
{
	int hour,car,ch;
	float fhp,chp,price1,price2,total;
	
printf("									_._											  ");
printf("							   _.-="_-		 _									 ");
printf("						  _.-="   _-		  | ||"""""""---._______	 __..		");
printf("			  ___.===""""-.______-,,,,,,,,,,,,`-''----" """""	   """""  __'	   ");
printf("	   __.--""	 __		,'				   o \		   __		[__|	   ");
printf("  __-""=======.--""  ""--.=================================.--""  ""--.=======:	  ");
printf(" ]	   [w] : /		\ : |========================|	: /		\ :  [w] :	  ");
printf(" V___________:|		  |: |========================|	:|		  |:   _-"	   ");
printf("  V__________: \		/ :_|=======================/_____: \		/ :__-"		 ");
printf("  -----------'  ""____""  `-------------------------------'  ""____""				");
	
	printf("----------------------------------------------\n");
	printf("				   CAR INFO				   \n");
	printf("----------------------------------------------\n");
	printf("1. BMW 518i\n");
	printf("1. Hummer H3\n");
	printf("1. Mercedes Benz SLK\n");
	printf("----------------------------------------------\n");
	printf("Enter car :");
	scanf("%d",&car);
	printf("Enter car hours :");
	scanf("%d",&hour);
	
	switch(car)
	{
			   case 1:
					fhp=5;
					ch=hour-5;
					chp=2;
					
					break;
					case 2:
						 fhp=4;
						 ch=hour-5;
						 chp=1;
						 break;
						 case 3:
							  fhp=6;
							  ch=hour-5;
							  chp=3;
							  break;
							  default:
									  printf("INVALID CODE\n");
									  break;
	}
	if(hour<=5)
	{
			   price1=fhp*hour;
			   price2=0;
	}
	else if(hour>5)
	{
		 price1=5*fhp;
		 price2=ch*chp;
	}
	total=price1+price2;
	printf("----------------------------------------------\n");
	printf("					BILL					  \n");
	printf("----------------------------------------------\n");
	printf("car\t\t:%d\n",car);						 
	printf("total hours\t:%d\n",hour);
	printf("price (first hour)\t:RM%.2f\n",price1);												  
	printf("price (consequent hour)\t:RM%.2f\n",price2);												  
	printf("payment\t\t:RM%.2f\n",total);
	
	system("pause");
} 


Is This A Good Question/Topic? 0
  • +

Replies To: ascii art

#2 krum110487  Icon User is offline

  • D.I.C Regular

Reputation: 39
  • View blog
  • Posts: 291
  • Joined: 07-February 09

Re: ascii art

Posted 09 March 2009 - 02:09 PM

View Postknight_t, on 9 Mar, 2009 - 12:39 PM, said:

Hello all,im new to programming world and this is my assignment for computer procramming.
I got some problem here,my ascii arts are not allign properly when i run the program and there is some error in ascii art.Anyone can help me?
"I copy this directly from my dev c++"

#include<stdio.h>
#include<stdlib.h>

int main()
{
	int hour,car,ch;
	float fhp,chp,price1,price2,total;
	
printf("									_._											  ");
printf("							   _.-="_-		 _									 ");
printf("						  _.-="   _-		  | ||"""""""---._______	 __..		");
printf("			  ___.===""""-.______-,,,,,,,,,,,,`-''----" """""	   """""  __'	   ");
printf("	   __.--""	 __		,'				   o \		   __		[__|	   ");
printf("  __-""=======.--""  ""--.=================================.--""  ""--.=======:	  ");
printf(" ]	   [w] : /		\ : |========================|	: /		\ :  [w] :	  ");
printf(" V___________:|		  |: |========================|	:|		  |:   _-"	   ");
printf("  V__________: \		/ :_|=======================/_____: \		/ :__-"		 ");
printf("  -----------'  ""____""  `-------------------------------'  ""____""				");
	
	printf("----------------------------------------------\n");
	printf("				   CAR INFO				   \n");
	printf("----------------------------------------------\n");
	printf("1. BMW 518i\n");
	printf("1. Hummer H3\n");
	printf("1. Mercedes Benz SLK\n");
	printf("----------------------------------------------\n");
	printf("Enter car :");
	scanf("%d",&car);
	printf("Enter car hours :");
	scanf("%d",&hour);
	
	switch(car)
	{
			   case 1:
					fhp=5;
					ch=hour-5;
					chp=2;
					
					break;
					case 2:
						 fhp=4;
						 ch=hour-5;
						 chp=1;
						 break;
						 case 3:
							  fhp=6;
							  ch=hour-5;
							  chp=3;
							  break;
							  default:
									  printf("INVALID CODE\n");
									  break;
	}
	if(hour<=5)
	{
			   price1=fhp*hour;
			   price2=0;
	}
	else if(hour>5)
	{
		 price1=5*fhp;
		 price2=ch*chp;
	}
	total=price1+price2;
	printf("----------------------------------------------\n");
	printf("					BILL					  \n");
	printf("----------------------------------------------\n");
	printf("car\t\t:%d\n",car);						 
	printf("total hours\t:%d\n",hour);
	printf("price (first hour)\t:RM%.2f\n",price1);												  
	printf("price (consequent hour)\t:RM%.2f\n",price2);												  
	printf("payment\t\t:RM%.2f\n",total);
	
	system("pause");
} 


there are only 80 characters allowed on one line for a command line window.

also if I am not mistaken you are missing the end of line character "\n"

printf("								   _._										\n");
printf("							  _.-="_-		 _							   \n");
printf("						 _.-="   _-		  | ||"""""""---._______	 __..  \n");
printf("			 ___.===""""-.______-,,,,,,,,,,,,`-''----" """""	   """""  __' \n");
printf("	  __.--""	 __		,'				   o \		   __		[__| \n");
printf(" __-""=======.--""  ""--.=================================.--""  ""--.=======:\n");
printf("]	   [w] : /		\ : |========================|	: /		\ :  [w] :\n");
printf("V___________:|		  |: |========================|	:|		  |:   _-" \n");
printf(" V__________: \		/ :_|=======================/_____: \		/ :__-"   \n");
printf(" -----------'  ""____""  `-------------------------------'  ""____""		  \n");

This post has been edited by krum110487: 09 March 2009 - 02:11 PM

Was This Post Helpful? 0
  • +
  • -

#3 knight_t  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-March 09

Re: ascii art

Posted 10 March 2009 - 08:58 AM

I already include \n at the end of the line,but still there is error.Its starting from the 2nd line.

thanks bro.:)

This post has been edited by knight_t: 10 March 2009 - 08:59 AM

Was This Post Helpful? 0
  • +
  • -

#4 krum110487  Icon User is offline

  • D.I.C Regular

Reputation: 39
  • View blog
  • Posts: 291
  • Joined: 07-February 09

Re: ascii art

Posted 10 March 2009 - 10:27 AM

oh :-P I didn't even notice the quotations within the ascii art.

you have to negate any quote within the ascii art with \"

just like the end.

it is getting confused at where the quote ends and begins.

printf("								   _._										\n");
printf("							  _.-=\"_-		 _							   \n");
printf("						 _.-=\"   _-		  | ||\"\"\"\"\"\"\"---._______	 __..  \n");
printf("			 ___.===\"\"\"\"-.______-,,,,,,,,,,,,`-''----" \"\"\"\"\"	   \"\"\"\"\"  __' \n");
printf("	  __.--\"\"	 __		,'				   o \		   __		[__| \n");
printf(" __-\"\"=======.--\"\"  \"\"--.=================================.--\"\"  \"\"--.=======:\n");
printf("]	   [w] : /		\ : |========================|	: /		\ :  [w] :\n");
printf("V___________:|		  |: |========================|	:|		  |:   _-\" \n");
printf(" V__________: \		/ :_|=======================/_____: \		/ :__-\"   \n");
printf(" -----------'  \"\"____\"\"  `-------------------------------'  \"\"____\"\"		  \n");

This post has been edited by krum110487: 10 March 2009 - 10:30 AM

Was This Post Helpful? 0
  • +
  • -

#5 Hyper  Icon User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: ascii art

Posted 10 March 2009 - 10:34 AM

There are 80 characters wide in a console (width = 80)
There are 25-50 (25 non-full screen, 50 full screen) tall (height = 25-50)

From there you can easily format pictures.
WIDTH = 80
HEIGHT = 25 (better safe than sorry)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1