11 Replies - 1007 Views - Last Post: 16 August 2007 - 09:39 AM
#1
this is my 1st project and i don't even know how to start
Posted 14 August 2007 - 01:18 AM
so my instructor gave me a project in which i should make a program that adds, edits, deletes and searches for costumers..
my skill level is only in the if statements so i'm really in trouble.. i'm desperate for help.
any advice where should i start? thank you so much!
Replies To: this is my 1st project and i don't even know how to start
#2
Re: this is my 1st project and i don't even know how to start
Posted 14 August 2007 - 02:28 AM
suzette, on 14 Aug, 2007 - 01:18 AM, said:
so my instructor gave me a project in which i should make a program that adds, edits, deletes and searches for costumers..
my skill level is only in the if statements so i'm really in trouble.. i'm desperate for help.
any advice where should i start? thank you so much!
#3
Re: this is my 1st project and i don't even know how to start
Posted 14 August 2007 - 02:58 AM
i am new in programming and all i know are IF statements..
thanks for bearing with me..
vijaysnkar, on 14 Aug, 2007 - 02:28 AM, said:
suzette, on 14 Aug, 2007 - 01:18 AM, said:
so my instructor gave me a project in which i should make a program that adds, edits, deletes and searches for costumers..
my skill level is only in the if statements so i'm really in trouble.. i'm desperate for help.
any advice where should i start? thank you so much!
#4
Re: this is my 1st project and i don't even know how to start
Posted 14 August 2007 - 05:51 AM
#5
Re: this is my 1st project and i don't even know how to start
Posted 14 August 2007 - 06:01 AM
Show us the code and in which platform are you working around?
suzette, on 14 Aug, 2007 - 02:58 AM, said:
i am new in programming and all i know are IF statements..
thanks for bearing with me..
vijaysnkar, on 14 Aug, 2007 - 02:28 AM, said:
suzette, on 14 Aug, 2007 - 01:18 AM, said:
so my instructor gave me a project in which i should make a program that adds, edits, deletes and searches for costumers..
my skill level is only in the if statements so i'm really in trouble.. i'm desperate for help.
any advice where should i start? thank you so much!
Do some reading in the Tutorials present in this site and try to get a knowledge in C++.
This is what we can say you right now.
vijaysnkar, on 14 Aug, 2007 - 05:59 AM, said:
Show us the code and in which platform are you working around?
suzette, on 14 Aug, 2007 - 02:58 AM, said:
i am new in programming and all i know are IF statements..
thanks for bearing with me..
vijaysnkar, on 14 Aug, 2007 - 02:28 AM, said:
suzette, on 14 Aug, 2007 - 01:18 AM, said:
so my instructor gave me a project in which i should make a program that adds, edits, deletes and searches for costumers..
my skill level is only in the if statements so i'm really in trouble.. i'm desperate for help.
any advice where should i start? thank you so much!
#6
Re: this is my 1st project and i don't even know how to start
Posted 14 August 2007 - 07:51 AM
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define p printf
#define s scanf
main()
{
char fname1, lname1, street1, city1, prov1,fname2, lname2, street2, city2, prov2,fname3, lname3, street3, city3, prov3,fname4, lname4, street4, city4, prov4,fname5, lname5, street5, city5, prov5, search;
int age5,age4,age3,age2,age1,choice;
clrscr();
begin:
p("Project 1");
p("\n1) Add Costumer");
p("\n2) Edit Costumer");
p("\n3) Search Costumer");
p("\n4) Delete Costumer");
p("\n5) Exit");
p("\n\nEnter Choice: ");
s("%i",&choice);
if (choice==1)
{one:
clrscr();
p("First Name: ");s("%s",&fname1);
p("\nLast Name: ");s("%s",&lname1);
p("\nAge: ");s("%i",&age1);
p("\nAddress: Street: ");s("%s",&street1);
p("\n City: ");s("%s",&city1);
p("\n Province: ");s("%s",&prov1);
p("Press any key to return to main menu...");
s(" ");
goto begin;
two:
clrscr();
p("First Name: ");s("%s",&fname2);
p("\nLast Name: ");s("%s",&lname2);
p("\nAge: ");s("%i",&age2);
p("\nAddress: Street: ");s("%s",&street2);
p("\n City: ");s("%s",&city2);
p("\n Province: ");s("%s",&prov2);
p("Press any key to return to main menu...");
s(" ");
goto begin;
three:
clrscr();
p("First Name: ");s("%s",&fname3);
p("\nLast Name: ");s("%s",&lname3);
p("\nAge: ");s("%i",&age3);
p("\nAddress: Street: ");s("%s",&street3);
p("\n City: ");s("%s",&city3);
p("\n Province: ");s("%s",&prov3);
p("Press any key to return to main menu...");
s(" ");
goto begin;
four:
clrscr();
p("First Name: ");s("%s",&fname4);
p("\nLast Name: ");s("%s",&lname4);
p("\nAge: ");s("%i",&age4);
p("\nAddress: Street: ");s("%s",&street4);
p("\n City: ");s("%s",&city4);
p("\n Province: ");s("%s",&prov4);
p("Press any key to return to main menu...");
s(" ");
goto begin;
five:
clrscr();
p("First Name: ");s("%s",&fname5);
p("\nLast Name: ");s("%s",&lname5);
p("\nAge: ");s("%i",&age5);
p("\nAddress: Street: ");s("%s",&street5);
p("\n City: ");s("%s",&city5);
p("\n Province: ");s("%s",&prov5);
p("Press any key to return to main menu...");
s(" ");
goto begin;}
if(choice==2)
{clrscr();
p("Edit which costumer: ");
p("\n1) %s %s",fname1,lname1);
p("\n2) %s %s",fname2,lname2);
p("\n3) %s %s",fname3,lname3);
p("\n4) %s %s",fname4,lname4);
p("\n5) %s %s",fname5,lname5);
s("%i",&choice);
edit:
if (choice==1)
goto one;
else if (choice==2)
goto two;
else if (choice==3)
goto three;
else if (choice==4)
goto four;
else if (choice==5)
goto five;
else
p("invalid input");
goto edit;
}
if (choice==3)
{clrscr();
p("enter last name: ");
s("%s",&search);
if (search==lname1)
{p("%s %s",fname1,lname1);p("\nAge: %i",age1);
p("\nAddress: %s, %s, %s",street1,city1,prov1);
p("\nPress any key to return to main menu...");
s(" ");
goto begin;
}
if (search==lname2)
{p("%s %s",fname1,lname2);p("\nAge: %i",age2);
p("\nAddress: %s, %s, %s",street2,city2,prov2);
p("\nPress any key to return to main menu...");
s(" ");
goto begin;
}
if (search==lname3)
{p("%s %s",fname3,lname3);p("\nAge: %i",age3);
p("\nAddress: %s, %s, %s",street3,city3,prov3);
p("\nPress any key to return to main menu...");
s(" ");
goto begin;
}
if (search==lname4)
{p("%s %s",fname4,lname4);p("\nAge: %i",age4);
p("\nAddress: %s, %s, %s",street4,city4,prov4);
p("\nPress any key to return to main menu...");
s(" ");
goto begin;
}
if (search==lname5)
{p("%s %s",fname5,lname5);p("\nAge: %i",age5);
p("\nAddress: %s, %s, %s",street5,city5,prov5);
p("Press any key to return to main menu...");
s(" ");
goto begin;
}
else
p("No entry");
p("\nPress any key to return to main menu...");
s(" ");
goto begin;
}
if (choice==4)
clrscr();
{p("Delete which profile: ");
p("\n1) %s %s",fname1,lname1);
p("\n2) %s %s",fname2,lname2);
p("\n3) %s %s",fname3,lname3);
p("\n4) %s %s",fname4,lname4);
p("\n5) %s %s",fname5,lname5);
s("%i",&choice);
if (choice==5)
{goto exit;}
if (choice<1&&choice>5)
{p("invalid input");}
goto begin;
exit:
getch();
return 0;
}
i'm using borland turbo c++ ver. 3
actually i'm kinda shy to show you this because i know there is a lot more better way to make this..
"if (choice==4)" is not finished because i dont know how to do that also.. and one last thing, how can i make the goto statement work? i tried to put delay(750) on it but it gives back an error..
#7
Re: this is my 1st project and i don't even know how to start
Posted 14 August 2007 - 08:39 AM
1. Don't #define your printf and scanf functios. Replace all the p's and s's with printfs and scanfs respectively.
2. Remove the clrscr()s. They're non standard.
3. Indent your code. That makes is more readable.
4. Rewrite the following set of printf statements as one:
p("Project 1");
p("\n1) Add Costumer");
p("\n2) Edit Costumer");
p("\n3) Search Costumer");
p("\n4) Delete Costumer");
p("\n5) Exit");
p("\n\nEnter Choice: ");
Write them as
printf("Project 1\n1) Add Costumer\n2) Edit Costumer\n3) Search Costumer\n4) Delete Costumer\n5) Exit\n\nEnter Choice: ");
scanf("%i",&choice);
Use code tags like I have.
Also, rather than me helping you, go to the link I gave above. You really need to do some learning if you want to get anywhere.
#8
Re: this is my 1st project and i don't even know how to start
Posted 16 August 2007 - 02:38 AM
#9
Re: this is my 1st project and i don't even know how to start
Posted 16 August 2007 - 05:54 AM
#10
Re: this is my 1st project and i don't even know how to start
Posted 16 August 2007 - 06:20 AM
#11
Re: this is my 1st project and i don't even know how to start
Posted 16 August 2007 - 07:59 AM
thanks,
#12
Re: this is my 1st project and i don't even know how to start
Posted 16 August 2007 - 09:39 AM
|
|

New Topic/Question
Reply




MultiQuote



|