🔒 Closed Turbo C Project

Status
Not open for further replies.

cie1998

Established
Baka po may makatulong sakin hehe di ko alam kung tama ba ito😨 Baka po pwede pong pa help about sa codes ko di po kasi gumagana yung Display hehe tska po pa help na din sa price kunyari po may item pa akong idadagdag yung sa price niya ganto po pala need gawin not sure kung tama yung system ko received_332280084101612.jpeg


ito po yung codes ko :
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
char menu;
int c;
do
{
clrscr();
printf("\n\t\tPROGRAMMED BY: CIELO MARCELINO");
printf("\n\t\t\t IT 1A1");
printf("\n\t ---------Select your choice---------\n");
printf("\n\t\t1. ADD INVENTORY RECORD\n\t\t2. DELETE INVENTORY RECORD");
printf("\n\t\t3. UPDATE INVENTORY RECORD\n\t\t4. DISPLAY INVENTORY RECORD");
printf("\n\t\t5. EXIT");
printf("\n\n\t ------------------------------------\n");
printf("\nChoose Transaction:");
scanf("%d", &c);
printf("\n");
clrscr();

if (c==1)//ADD RECORD
{
char try;
do
{
clrscr();
FILE *ADD;
int code,code1,qnt;
char name[30],des[30],brnd[30],unit[30];
float uc;
ADD = fopen("pos.txt", "a");
printf("------------------------------------------------------------\n");
printf("\t\t ADD INVENTORY RECORD");
printf("\n------------------------------------------------------------");
printf("\nItem Code:");
scanf("%d",&code);
printf("Item Name:");
scanf(" %s",&name);
printf("Item Description:");
scanf(" %s", des);
printf("Item Brand:");
scanf("%s", &brnd);
printf("Quantity:");
scanf("%d", &qnt);
printf("Unit:");
scanf("%s",&unit);
uc=qnt * 14;
printf("Unit Cost:%f\n",uc);
fprintf(ADD,"%d\t%s\t%s\t%s\t%d\t%s\t%f\n",code,name,des,brnd,qnt,unit,uc);
fclose(ADD);
printf("\nRecord Successfully Added");
printf("\nDo you want to add another record?[Y/N]:");
scanf(" %c",&try);
}
while (try=='y'||try=='Y');
}
else if(c==4)//DISPLAY RECORD
{
char try4;
do
{
clrscr();
FILE *DISP;
int flag=0,rec,code1,qnt1;
char name1[50],des1[50],brnd1[30],unit1[30];
float uc1;
DISP=fopen("pos.txt","r");
printf("------------------------------------------------------------\n");
printf("\t\t DISPLAY INVENTORY RECORD");
printf("\n------------------------------------------------------------");
printf("\nEnter the item code you want to search: ");

scanf("%d",&rec);

while(fscanf(DISP,"%d %s %s %s %d %s %f\n",&code1,&name1,&des1,&brnd1,&qnt1,&unit1,&uc1)!=EOF)
{
if (rec == code1)
{
printf("ITEM NAME: %s\n",name1);
printf("ITEM DESCRIPTION: %s\n",des1);
printf("BRAND: %s\n",brnd1);
printf("QUANTITY: %d\n",qnt1);
printf("UNIT; %s\n",unit1);
printf("UNIT COST: %f\n",uc1);
flag=1;
}
}
if (flag==0)
{
printf("\n No Record Found!");
}
fclose(DISP);
printf("\nSearch Again?[Y/N]:");
scanf(" %c",&try4);
}
while(try4=='y'||try4=='Y');
}
else if(c==2)//DELETE RECORD
{
char try2;
do
{
clrscr();
FILE *DEL,*TEMP;
int f=0,code2,no,qnt;
char name[50],des[50],brnd[30],unit[30],sure;
float uc;

DEL =fopen("pos.txt","r");
TEMP =fopen("temppos.txt","w");
printf("------------------------------------------------------------\n");
printf("\t\t DELETE RECORD");
printf("\n------------------------------------------------------------");
printf("\nEnter Item Code: ");
scanf(" %d",&no);
printf("Are you sure you want to delete this\n\t record? Y/N : ");
scanf(" %c",&sure);
if (sure == 'Y' || sure == 'y'){
while (fscanf(DEL,"%d %s %s %s %d %s %f\n",&code2,&name,&des,&brnd,&qnt,&unit,&uc)!=EOF)
{

if (no==code2)
{
f=1;
printf(" \nSuccesfully Deleted\n");
}
else
{
fprintf(TEMP,"%d %s %s %s %d %s %f\n",code2,name,des,brnd,qnt,unit,uc);
}
}
if (f==0)
{
printf("\nRecord not found\n");
}
fclose(DEL);
fclose(TEMP);

DEL =fopen("pos.txt","w");
fclose(DEL);

DEL=fopen("pos.txt","a");
TEMP=fopen("temppos.txt","r");
while (fscanf(TEMP,"%d %s %s %s %d %s %f",&code2,&name,&des,&brnd,&qnt,&unit,&uc)!=EOF)
{
fprintf(DEL,"%d %s %s %s %d %s %f\n",code2,name,des,brnd,qnt,unit,uc);
}
fclose(DEL);
fclose(TEMP);

TEMP =fopen("temppos.txt","w");
fclose(DEL);
}
else
{
printf("\nInvalid Choice!\nPlease Try Again!");
}
printf(" \n\nDelete Another Records?:[Y/N]");
scanf(" %c",&try2);
}
while (try2=='y'||try2=='y');
}
else if(c==3)//UPDATE RECORD
{
char try3;
do
{
clrscr();
FILE*UPDATE, *TEMPO1;
UPDATE=fopen("pos.txt","r");
TEMPO1=fopen("temppos.txt","a");

int flag=0,code3,qnt3;
char name3[30],des3[30],brnd3[30],unit3[30];
float uc3;

int code1,num1,qnt1;
char name1[30],des1[30],brnd1[30],unit1[30];
float uc1;

printf("------------------------------------------------------------\n");
printf("\t\t UPDATE RECORD");
printf("\n------------------------------------------------------------");
printf("\nEnter the item code you want to update: ");

scanf("%d",&num1);

while(fscanf(UPDATE,"%d %s %s %s %d %s %f\n",&code1,&name1,&des1,&brnd1,&qnt1,&unit1,&uc1)!=EOF);
{
if(code1==num1)
{
flag=1;
printf("\n\t\t CURRENT RECORD");
printf("\nItem Code: %d",code1);
printf("\nItem Name: %s",name1);
printf("\nItem Description: %s",des1);
printf("\nBrand: %s",brnd1);
printf("\nQuantity: %d",qnt1);
printf("\nUnit: %s",unit1);
printf("\nUnit Cost: %f",uc1);
printf("\n\t\t UPDATE RECORD");
printf("\n\nEnter Item Name: ");
gets(name3);
gets(name3);
printf("\nEnter Item Description: ");
gets(des3);
printf("\nEnter Brand: ");
scanf("%s",&brnd3);
printf("\nEnter Quantity: ");
scanf("%d",&qnt3);
printf("\nEnter Unit: ");
scanf("%s",&unit3);
uc3=qnt3 * 14;
printf("\nUnit Cost: %f",uc3);
fprintf(TEMPO1
,"%d %s %s %s %d %s %f\n",code1,name3,des3,brnd3,qnt3,unit3,uc3);
printf("\nRecord Successfully updated!");
}
else
{
fprintf(TEMPO1,"%d %s %s %s %d %s %f\n",code1,name1,des1,brnd1,qnt1,unit1,uc1);
}
}
if(flag==0)
{
printf("Record Not found");
}
fclose(UPDATE);
fclose(TEMPO1);

remove("pos.txt");
rename("temppos.txt","pos.txt");

printf("\nUpdate Another Records?:[Y/N]");
scanf(" %c",&try3);
}
while (try3=='Y'||try3=='y');
}
else if(c==5)//EXIT
{
exit(1);
}
else
{
printf("\nSorry your choice is wrong");
}
printf("\n\nReturn to main menu? [Y/N]: ");
scanf(" %c", &menu);
}
while(menu=='y'||menu=='Y');
getch();
}

Maraming salamat po ❤😊
 
Running already. You just have to debug few lines of codes where you used non identifier words and some reserved words. after that, it may run smoothly and correctly.


620132
620134
620136
620137
620138
 
  • Like
Reactions: rxe
Status
Not open for further replies.

About this Thread

  • 2
    Replies
  • 560
    Views
  • 3
    Participants
Last reply from:
aa1012

Trending Topics

Online now

Members online
342
Guests online
630
Total visitors
972

Forum statistics

Threads
2,274,598
Posts
28,957,114
Members
1,234,336
Latest member
pringles_original12
Back
Top