Hey everyone, my group and I have this finals project that we'll have to defend. It involves ASCII characters for the table. We've managed to fix the table and everything but no matter what we do, our program won't compute. Here's the program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <graphics.h>

main()
{
clrscr ();
{
int x,price=0,qty=0,subtotal=0,total=0;
char item[20];



	for(x=8;x<=69;x++)
	{gotoxy(x,6);textcolor(5);cprintf("Í");
	gotoxy(x,25);textcolor(5);cprintf("Í");
	}
	for(x=7;x<=25;x++)
	{gotoxy(8,x);textcolor(5);cprintf("º");
	gotoxy(70,x);textcolor(5);cprintf("º");
	}
	for(x=10;x<=68;x++)
	{gotoxy(x,7);textcolor(5);cprintf("Í");
	 gotoxy(x,24);textcolor(5);cprintf("Í");
	 gotoxy(x,9);textcolor(5);cprintf("Í");
	 gotoxy(x,10);textcolor(5);cprintf("Í");
	 }
	 for(x=8;x<=20;x++)
	 {gotoxy(10,x);textcolor(5);cprintf("º");
	  gotoxy(68,x);textcolor(5);cprintf("º");
	 }

	 for(x=11;x<=24;x++)
	 {gotoxy(10,x);textcolor(5);cprintf("º");
	  gotoxy(68,x);textcolor(5);cprintf("º");
	 }
	 for(x=11;x<=23;x++)
	 {gotoxy(20,x);textcolor(5);cprintf("³");
	 gotoxy(30,x);textcolor(5);cprintf("³");
	 gotoxy(40,x);textcolor(5);cprintf("³");
	 gotoxy(50,x);textcolor(5);cprintf("³");

	 }

	 gotoxy(25,8);
	 printf("BSIT-NW I-B");
	 gotoxy(49,8);
	 printf("GROUP 2");


	 {
	 gotoxy(8,6);textcolor(5);cprintf("É");
	 gotoxy(70,6);textcolor(5);cprintf("»");
	 gotoxy(8,25);textcolor(5);cprintf("È");
	 gotoxy(70,25);textcolor(5);cprintf("¼");
	 }
	 {
	 gotoxy(10,7);textcolor(5);cprintf("É");
	 gotoxy(68,7);textcolor(5);cprintf("»");
	 gotoxy(10,9);textcolor(5);cprintf("È");
	 gotoxy(68,9);textcolor(5);cprintf("¼");
	 }
	 {
	 gotoxy(10,10);textcolor(5);cprintf("É");
	 gotoxy(68,10);textcolor(5);cprintf("»");
	 gotoxy(10,24);textcolor(5);cprintf("È");
	 gotoxy(68,24);textcolor(5);cprintf("¼");
	 }
	 {

	 gotoxy(13,11);
	 printf("Item");
	 gotoxy(23,11);
	 printf("Price");
	 gotoxy(33,11);
	 printf("Qty.");
	 gotoxy(42,11);
	 printf("Subtotal");
	 gotoxy(53,11);
	 printf("Total/Change\n");

	 gotoxy(13,12);
	 scanf("%s",&item);
	 gotoxy(23,12);
	 scanf("%i",&price);
	 gotoxy(33,12);
	 scanf("%i",&qty);

	 gotoxy(42,12);
	 scanf("%i",subtotal);
	 gotoxy(53,12);
	 scanf("%i",&total);

	 }
         return 0;

}

}

The first formula is subtotal=price*qty. We don't have the formula for the total yet since we first need to make the subtotal work for the total to work in turn. Hope anyone can help us! Thanks! <3

our program won't compute

At least two primitive problems, to fix, change:

scanf("%s", &item);

to

scanf("%s", item);

and

scanf("%i",subtotal);

to

scanf("%i", [B]&[/B]subtotal);

thank you so much! <3 but where do i put the formula? that's our current problem... no matter where we put it, it won't compute. thank you again!

Make it a function of its own, so you'll have ...

int CalcSubTotal(const int qty, const int price)
{
    // Calculate the subtotal here and return the calculated value ...
//   const int result = ???
//   return result;
}

Can we ask you a huge favor? We can't make the program compute no matter what we do, so could we ask you to arrange the formulas where it should be put? We also have a 20-item limit, if that can be of any help. The subtotal is the price per item, and the total is the price of all entered items.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <graphics.h>

main()
{
clrscr ();
{
int x,price=0,qty=0,subtotal=0,total=0;
char item[20];



	for(x=8;x<=69;x++)
	{gotoxy(x,6);textcolor(5);cprintf("Í");
	gotoxy(x,25);textcolor(5);cprintf("Í");
	}
	for(x=7;x<=25;x++)
	{gotoxy(8,x);textcolor(5);cprintf("º");
	gotoxy(70,x);textcolor(5);cprintf("º");
	}
	for(x=10;x<=68;x++)
	{gotoxy(x,7);textcolor(5);cprintf("Í");
	 gotoxy(x,24);textcolor(5);cprintf("Í");
	 gotoxy(x,9);textcolor(5);cprintf("Í");
	 gotoxy(x,10);textcolor(5);cprintf("Í");
	 }
	 for(x=8;x<=20;x++)
	 {gotoxy(10,x);textcolor(5);cprintf("º");
	  gotoxy(68,x);textcolor(5);cprintf("º");
	 }

	 for(x=11;x<=24;x++)
	 {gotoxy(10,x);textcolor(5);cprintf("º");
	  gotoxy(68,x);textcolor(5);cprintf("º");
	 }
	 for(x=11;x<=23;x++)
	 {gotoxy(20,x);textcolor(5);cprintf("³");
	 gotoxy(30,x);textcolor(5);cprintf("³");
	 gotoxy(40,x);textcolor(5);cprintf("³");
	 gotoxy(50,x);textcolor(5);cprintf("³");

	 }

	 gotoxy(25,8);
	 printf("BSIT-NW I-B");
	 gotoxy(49,8);
	 printf("GROUP 2");


	 {
	 gotoxy(8,6);textcolor(5);cprintf("É");
	 gotoxy(70,6);textcolor(5);cprintf("»");
	 gotoxy(8,25);textcolor(5);cprintf("È");
	 gotoxy(70,25);textcolor(5);cprintf("¼");
	 }
	 {
	 gotoxy(10,7);textcolor(5);cprintf("É");
	 gotoxy(68,7);textcolor(5);cprintf("»");
	 gotoxy(10,9);textcolor(5);cprintf("È");
	 gotoxy(68,9);textcolor(5);cprintf("¼");
	 }
	 {
	 gotoxy(10,10);textcolor(5);cprintf("É");
	 gotoxy(68,10);textcolor(5);cprintf("»");
	 gotoxy(10,24);textcolor(5);cprintf("È");
	 gotoxy(68,24);textcolor(5);cprintf("¼");
	 }
	 {

	 gotoxy(13,11);
	 printf("Item");
	 gotoxy(23,11);
	 printf("Price");
	 gotoxy(33,11);
	 printf("Qty.");
	 gotoxy(42,11);
	 printf("Subtotal");
	 gotoxy(53,11);
	 printf("Total Change");


	 gotoxy(13,12);
	 scanf("%s",item);
	 gotoxy(23,12);
	 scanf("%i",&price);
	 gotoxy(33,12);
	 scanf("%i",&qty);

	 gotoxy(42,12);
	 scanf("%i",&subtotal);
	 gotoxy(53,12);
	 scanf("%i",&total);

	 }
         return 0;

}

}

Thank you so much and sorry for the bother!

The best place to put the calculation is after you've read the data used in the calculation.
The best place to output the answers is after you've done the calculations.

And you need to use CODE tags as described in The Rules you read when you signed up. Did you miss that paragraph?

Sorry, will remember to do that. I guess we were in a hurry at the time, and I sort of didn't bother. Sorry again!

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