46 Replies - 3174 Views - Last Post: 06 October 2012 - 09:37 AM
#1
Password C++
Posted 30 September 2012 - 06:52 AM
Ex.
Enter Password : 123
Incorrect!
Enter Password: 321
Correct!
Execute code inside
Thanks in advance for help.
Replies To: Password C++
#2
Re: Password C++
Posted 30 September 2012 - 06:55 AM
password = "" while password not equal to 321 do get new password from user end
#3
Re: Password C++
Posted 30 September 2012 - 07:11 AM
And also im thinking about input that can get both int and char.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
int main()
{
/* char pass[50];
cout<<"Enter Password: ";
cin>>pass;
if (pass =="test"){
cout<<"\n";
cout<<"Correct!";
system("pause");*/
char password;
char test;
password=test;
cout<<"Enter Pssword: ";
cin>>password;
while(password !=test);
cout<<"Enter Password; ";
return 0;
}
CODE CODE CODE CODE CODE CODE CODE CODE
/*else{
cout<<"Incorrect";
sleep(5000);
return 0;
}
} */
This post has been edited by Untalented: 30 September 2012 - 07:16 AM
#5
Re: Password C++
Posted 30 September 2012 - 07:43 AM
the string password part gives me errors and im not sure where to paste my codes to make it work.
#include<iostream.h>
#include<string.h>
my user defined functions();
my user defined functions();
my user defined functions();
int main()
{
string password; //this gives me "Undefined symbol string error
cout<<"Enter Password: ";
cin>>password;
if(password=="test"){
cout<<"Correct!";
}
CODE CODE CODE
else{
cout<<"Incorrect"
return 0;
}
This is the actual code
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int design();
int input();
int menu();
int computation();
int main()
{
string password;
cout<<"Enter Password: ";
cin>>password;
if(password=="test"){
cout<<"Correct!";
}
design();
input();
menu();
computation();
getch();
return 0;
}
design()
{
clrscr();
gotoxy(5,4); textcolor(RED);
gotoxy(5,7); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,3); textcolor(RED);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"); gotoxy(5,5); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,4); cprintf("³"); gotoxy(5,4); cprintf("³"); gotoxy(5,6); cprintf("³"); gotoxy(71,6); cprintf("³"); gotoxy(71,4); cprintf("³");
gotoxy(5,9); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,11); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,14); cprintf("³"); gotoxy(5,14); cprintf("³"); gotoxy(21,14); cprintf("³"); gotoxy(37,14); cprintf("³"); gotoxy(54,14); cprintf("³");gotoxy(71,14); cprintf("³");
gotoxy(5,15); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,16); cprintf("³"); gotoxy(5,16); cprintf("³"); gotoxy(21,16); cprintf("³"); gotoxy(37,16); cprintf("³"); gotoxy(54,16); cprintf("³");gotoxy(71,16); cprintf("³");
gotoxy(5,17); cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
gotoxy(5,8); cprintf("³"); gotoxy(21,8); cprintf("³"); gotoxy(37,8); cprintf("³"); gotoxy(54,8); cprintf("³"); gotoxy(71,8); cprintf("³");
gotoxy(5,10); cprintf("³"); gotoxy(21,10); cprintf("³"); gotoxy(37,10); cprintf("³"); gotoxy(54,10); cprintf("³"); gotoxy(71,10); cprintf("³");
gotoxy(5,12); cprintf("³"); gotoxy(21,12); cprintf("³"); gotoxy(37,12); cprintf("³"); gotoxy(54,12); cprintf("³"); gotoxy(71,12); cprintf("³");
gotoxy(5,6); cprintf("³"); gotoxy(21,6); cprintf("³"); gotoxy(37,6); cprintf("³"); gotoxy(54,6); cprintf("³"); gotoxy(71,6); cprintf("³");
return 0;
}
input()
{
gotoxy(15,4); textcolor(YELLOW); cprintf(" í ° í ° í M C J O-L Y B E E í ° í ° í");
textcolor(LIGHTBLUE); gotoxy(12,6); cprintf("ITEMS");
gotoxy(24,6); cprintf("UNIT PRICE");
gotoxy(38,6); cprintf("QUANTITY ORDERED");
gotoxy(60,6); cprintf("AMOUNT");
textcolor(MAGENTA);
gotoxy(5,19); cprintf("TOTAL:");
gotoxy(5,21); cprintf("VAT:");
gotoxy(5,23); cprintf("TOTAL w/ VAT:");
gotoxy(50,21); cprintf("CASH:");
gotoxy(50,23); cprintf("CHANGE:");
textcolor(GREEN);
return 0;
}
menu()
{
float c=250, ddp=310, hw=220, bpw=160, sd=60, a, v, t,m, h;
gotoxy(6,8); cprintf("Chee-C Pizza");
gotoxy(6,10); cprintf("How-I-An");
gotoxy(6,12); cprintf("Hot Wings");
gotoxy(6,14); cprintf("Baked Potato");
gotoxy(6,16); cprintf("Softdrinks (L)");
gotoxy(25,8); cprintf("P250.00");
gotoxy(25,10); cprintf("P320.00");
gotoxy(25,12); cprintf("P220.00");
gotoxy(25,14); cprintf("P160.00");
gotoxy(25,16); cprintf("P60.00");
gotoxy(46,8); cin>>c; gotoxy(58,8); a=250.00*c; printf("P%.2f",a);
gotoxy(46,10); cin>>ddp; gotoxy(58,10); a=320.00*ddp; printf("P%.2f",a);
gotoxy(46,12); cin>>hw; gotoxy(58,12); a=220.00*hw; printf("P%.2f",a);
gotoxy(46,14); cin>>bpw; gotoxy(58,14); a=160.00*bpw; printf("P%.2f",a);
gotoxy(46,16); cin>>sd; gotoxy(58,16); a=60.00*sd; printf("P%.2f",a);
return 0;
}
computation()
{
float c, ddp, hw, bpw, sd, a, v, t,m, ch, tt;
gotoxy(12,19); t=250.00*c+320.00*ddp+220.00*hw+160.00*bpw+60.00*sd; printf("P%.2f",t);
gotoxy(10,21); v=0.1*t; printf("P%.2f",v);
gotoxy(19,23); tt=t+v; printf("P%.2f",tt);
gotoxy(56,21); cout<<"P"; cin>>m;
gotoxy(57,23); ch=m-(t+v); printf("P%.2f",ch);
return 0;
}
//if pass
}
else{
cout<<"Incorrect!";
}
}
#6
Re: Password C++
Posted 30 September 2012 - 07:55 AM
#7
Re: Password C++
Posted 30 September 2012 - 08:06 AM
Skydiver, on 30 September 2012 - 07:55 AM, said:
I dont have it. The school uses this so i have no choice. i have Dev C++ here but i need to create this using the old one.
Still not working.. Im getting 1 error and i know this is not the right structure.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int design();
int input();
int menu();
int computation();
int main()
{
// char password[50]=test; //undefined symbol test
char test,password;
cout<<"Enter Password: ";
cin>>password;
if(password==test){
cout<<"Correct!";
clrscr();
design();
input();
menu();
computation();
getch();
return 0;
}
//func
design()
{ //statement missing ;
clrscr();
gotoxy(5,4); textcolor(RED);
gotoxy(5,7); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,3); textcolor(RED);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"); gotoxy(5,5); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,4); cprintf("³"); gotoxy(5,4); cprintf("³"); gotoxy(5,6); cprintf("³"); gotoxy(71,6); cprintf("³"); gotoxy(71,4); cprintf("³");
gotoxy(5,9); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,11); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,14); cprintf("³"); gotoxy(5,14); cprintf("³"); gotoxy(21,14); cprintf("³"); gotoxy(37,14); cprintf("³"); gotoxy(54,14); cprintf("³");gotoxy(71,14); cprintf("³");
gotoxy(5,15); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,16); cprintf("³"); gotoxy(5,16); cprintf("³"); gotoxy(21,16); cprintf("³"); gotoxy(37,16); cprintf("³"); gotoxy(54,16); cprintf("³");gotoxy(71,16); cprintf("³");
gotoxy(5,17); cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
gotoxy(5,8); cprintf("³"); gotoxy(21,8); cprintf("³"); gotoxy(37,8); cprintf("³"); gotoxy(54,8); cprintf("³"); gotoxy(71,8); cprintf("³");
gotoxy(5,10); cprintf("³"); gotoxy(21,10); cprintf("³"); gotoxy(37,10); cprintf("³"); gotoxy(54,10); cprintf("³"); gotoxy(71,10); cprintf("³");
gotoxy(5,12); cprintf("³"); gotoxy(21,12); cprintf("³"); gotoxy(37,12); cprintf("³"); gotoxy(54,12); cprintf("³"); gotoxy(71,12); cprintf("³");
gotoxy(5,6); cprintf("³"); gotoxy(21,6); cprintf("³"); gotoxy(37,6); cprintf("³"); gotoxy(54,6); cprintf("³"); gotoxy(71,6); cprintf("³");
return 0;
}
input()
{
gotoxy(15,4); textcolor(YELLOW); cprintf(" í ° í ° í M C J O-L Y B E E í ° í ° í");
textcolor(LIGHTBLUE); gotoxy(12,6); cprintf("ITEMS");
gotoxy(24,6); cprintf("UNIT PRICE");
gotoxy(38,6); cprintf("QUANTITY ORDERED");
gotoxy(60,6); cprintf("AMOUNT");
textcolor(MAGENTA);
gotoxy(5,19); cprintf("TOTAL:");
gotoxy(5,21); cprintf("VAT:");
gotoxy(5,23); cprintf("TOTAL w/ VAT:");
gotoxy(50,21); cprintf("CASH:");
gotoxy(50,23); cprintf("CHANGE:");
textcolor(GREEN);
return 0;
}
menu()
{
float c=250, ddp=310, hw=220, bpw=160, sd=60, a, v, t,m, h;
gotoxy(6,8); cprintf("Chee-C Pizza");
gotoxy(6,10); cprintf("How-I-An");
gotoxy(6,12); cprintf("Hot Wings");
gotoxy(6,14); cprintf("Baked Potato");
gotoxy(6,16); cprintf("Softdrinks (L)");
gotoxy(25,8); cprintf("P250.00");
gotoxy(25,10); cprintf("P320.00");
gotoxy(25,12); cprintf("P220.00");
gotoxy(25,14); cprintf("P160.00");
gotoxy(25,16); cprintf("P60.00");
gotoxy(46,8); cin>>c; gotoxy(58,8); a=250.00*c; printf("P%.2f",a);
gotoxy(46,10); cin>>ddp; gotoxy(58,10); a=320.00*ddp; printf("P%.2f",a);
gotoxy(46,12); cin>>hw; gotoxy(58,12); a=220.00*hw; printf("P%.2f",a);
gotoxy(46,14); cin>>bpw; gotoxy(58,14); a=160.00*bpw; printf("P%.2f",a);
gotoxy(46,16); cin>>sd; gotoxy(58,16); a=60.00*sd; printf("P%.2f",a);
return 0;
}
computation()
{
float c, ddp, hw, bpw, sd, a, v, t,m, ch, tt;
gotoxy(12,19); t=250.00*c+320.00*ddp+220.00*hw+160.00*bpw+60.00*sd; printf("P%.2f",t);
gotoxy(10,21); v=0.1*t; printf("P%.2f",v);
gotoxy(19,23); tt=t+v; printf("P%.2f",tt);
gotoxy(56,21); cout<<"P"; cin>>m;
gotoxy(57,23); ch=m-(t+v); printf("P%.2f",ch);
}
else
{
cout<<"Incorrect";
}
cin.get();
return 0;
}
I cant find the error on line 33, someone please help me so that i can test and see if the code is running....
This post has been edited by Untalented: 30 September 2012 - 08:45 AM
#8
Re: Password C++
Posted 30 September 2012 - 08:59 AM
Anyway, if you are using Dev C++ this is how you declare a string:
#include <string>
int main()
{
std::string password;
std::string test("LetMeIn");
:
}
or
#include <string>
using namespace std;
int main()
{
string password;
string test("LetMeIn");
:
}
If you are using Turbo C++:
#include <string.h>
int main()
{
string password;
string test("LetMeIn");
:
}
On line 32, you wanted to define a function, but forgot to put in the return type.
This post has been edited by Skydiver: 30 September 2012 - 09:00 AM
#9
Re: Password C++
Posted 30 September 2012 - 09:07 AM
Skydiver, on 30 September 2012 - 08:59 AM, said:
Anyway, if you are using Dev C++ this is how you declare a string:
#include <string>
int main()
{
std::string password;
std::string test("LetMeIn");
:
}
or
#include <string>
using namespace std;
int main()
{
string password;
string test("LetMeIn");
:
}
If you are using Turbo C++:
#include <string.h>
int main()
{
string password;
string test("LetMeIn");
:
}
On line 32, you wanted to define a function, but forgot to put in the return type.
Im using borland compiler (The blue one) and that turbo c part when i use string it gives me an error undefined symbol string..
Line 32 what should i do? where should i put the return data type........
When i remove the password code my code is working fine.. the thing that gives error is just the password code.
This is working without the password code
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int design();
int input();
int menu();
int computation();
int main()
{
/* // char password[50]=test; //undefined symbol test
char test,password;
cout<<"Enter Password: ";
cin>>password;
if(password==test){
cout<<"Correct!";
clrscr(); */
design();
input();
menu();
computation();
getch();
return 0;
}
//func
design()
{ //statement missing ;
clrscr();
gotoxy(5,4); textcolor(RED);
gotoxy(5,7); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,3); textcolor(RED);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"); gotoxy(5,5); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,4); cprintf("³"); gotoxy(5,4); cprintf("³"); gotoxy(5,6); cprintf("³"); gotoxy(71,6); cprintf("³"); gotoxy(71,4); cprintf("³");
gotoxy(5,9); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,11); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,14); cprintf("³"); gotoxy(5,14); cprintf("³"); gotoxy(21,14); cprintf("³"); gotoxy(37,14); cprintf("³"); gotoxy(54,14); cprintf("³");gotoxy(71,14); cprintf("³");
gotoxy(5,15); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,16); cprintf("³"); gotoxy(5,16); cprintf("³"); gotoxy(21,16); cprintf("³"); gotoxy(37,16); cprintf("³"); gotoxy(54,16); cprintf("³");gotoxy(71,16); cprintf("³");
gotoxy(5,17); cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
gotoxy(5,8); cprintf("³"); gotoxy(21,8); cprintf("³"); gotoxy(37,8); cprintf("³"); gotoxy(54,8); cprintf("³"); gotoxy(71,8); cprintf("³");
gotoxy(5,10); cprintf("³"); gotoxy(21,10); cprintf("³"); gotoxy(37,10); cprintf("³"); gotoxy(54,10); cprintf("³"); gotoxy(71,10); cprintf("³");
gotoxy(5,12); cprintf("³"); gotoxy(21,12); cprintf("³"); gotoxy(37,12); cprintf("³"); gotoxy(54,12); cprintf("³"); gotoxy(71,12); cprintf("³");
gotoxy(5,6); cprintf("³"); gotoxy(21,6); cprintf("³"); gotoxy(37,6); cprintf("³"); gotoxy(54,6); cprintf("³"); gotoxy(71,6); cprintf("³");
return 0;
}
input()
{
gotoxy(15,4); textcolor(YELLOW); cprintf(" í ° í ° í M C J O-L Y B E E í ° í ° í");
textcolor(LIGHTBLUE); gotoxy(12,6); cprintf("ITEMS");
gotoxy(24,6); cprintf("UNIT PRICE");
gotoxy(38,6); cprintf("QUANTITY ORDERED");
gotoxy(60,6); cprintf("AMOUNT");
textcolor(MAGENTA);
gotoxy(5,19); cprintf("TOTAL:");
gotoxy(5,21); cprintf("VAT:");
gotoxy(5,23); cprintf("TOTAL w/ VAT:");
gotoxy(50,21); cprintf("CASH:");
gotoxy(50,23); cprintf("CHANGE:");
textcolor(GREEN);
return 0;
}
menu()
{
float c=250, ddp=310, hw=220, bpw=160, sd=60, a, v, t,m, h;
gotoxy(6,8); cprintf("Chee-C Pizza");
gotoxy(6,10); cprintf("How-I-An");
gotoxy(6,12); cprintf("Hot Wings");
gotoxy(6,14); cprintf("Baked Potato");
gotoxy(6,16); cprintf("Softdrinks (L)");
gotoxy(25,8); cprintf("P250.00");
gotoxy(25,10); cprintf("P320.00");
gotoxy(25,12); cprintf("P220.00");
gotoxy(25,14); cprintf("P160.00");
gotoxy(25,16); cprintf("P60.00");
gotoxy(46,8); cin>>c; gotoxy(58,8); a=250.00*c; printf("P%.2f",a);
gotoxy(46,10); cin>>ddp; gotoxy(58,10); a=320.00*ddp; printf("P%.2f",a);
gotoxy(46,12); cin>>hw; gotoxy(58,12); a=220.00*hw; printf("P%.2f",a);
gotoxy(46,14); cin>>bpw; gotoxy(58,14); a=160.00*bpw; printf("P%.2f",a);
gotoxy(46,16); cin>>sd; gotoxy(58,16); a=60.00*sd; printf("P%.2f",a);
return 0;
}
computation()
{
float c, ddp, hw, bpw, sd, a, v, t,m, ch, tt;
gotoxy(12,19); t=250.00*c+320.00*ddp+220.00*hw+160.00*bpw+60.00*sd; printf("P%.2f",t);
gotoxy(10,21); v=0.1*t; printf("P%.2f",v);
gotoxy(19,23); tt=t+v; printf("P%.2f",tt);
gotoxy(56,21); cout<<"P"; cin>>m;
gotoxy(57,23); ch=m-(t+v); printf("P%.2f",ch);
}
/*
else
{
cout<<"Incorrect";
}
cin.get();
return 0;
}
*/
This post has been edited by Untalented: 30 September 2012 - 09:27 AM
#10
Re: Password C++
Posted 30 September 2012 - 09:28 AM
As for line 32-33, didn't you learn how to declare and define functions? If so, I recommend reviewing your notes.
#11
Re: Password C++
Posted 30 September 2012 - 09:33 AM
Skydiver, on 30 September 2012 - 09:28 AM, said:
As for line 32-33, didn't you learn how to declare and define functions? If so, I recommend reviewing your notes.
#include<cstring> is not working either! its working in dev but not in the old one......
I cant find that missing semi colon..
As for the function as i said it was working without the password code.
This post has been edited by Untalented: 30 September 2012 - 09:35 AM
#12
Re: Password C++
Posted 30 September 2012 - 09:37 AM
design()
to
int design()
As for old C-style strings, there is no need to include any special header files, you just declare an array of characters, or allocate memory for it. For example:
char myString[100];
You should have covered this in your earlier classes.
#13
Re: Password C++
Posted 30 September 2012 - 09:41 AM
Skydiver, on 30 September 2012 - 09:37 AM, said:
design()
to
int design()
As for old C-style strings, there is no need to include any special header files, you just declare an array of characters, or allocate memory for it. For example:
char myString[100];
You should have covered this in your earlier classes.
I already tried making it int design it gives me a declaration syntax error.
When i add int to design it gives me a declaration syntax error.. when i delete the int. it gives me a statement missing ;
This post has been edited by Untalented: 30 September 2012 - 09:49 AM
#14
Re: Password C++
Posted 30 September 2012 - 09:51 AM
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int design();
int input();
int menu();
int computation();
int main()
{
char test,password;
cout<<"Enter Password: ";
cin>>password;
if(password==test){
cout<<"Correct!";
clrscr();
design();
input();
menu();
computation();
getch();
return 0;
}
design()
{ //statement missing ;
clrscr();
gotoxy(5,4); textcolor(RED);
gotoxy(5,7); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,3); textcolor(RED);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"); gotoxy(5,5); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,4); cprintf("³"); gotoxy(5,4); cprintf("³"); gotoxy(5,6); cprintf("³"); gotoxy(71,6); cprintf("³"); gotoxy(71,4); cprintf("³");
gotoxy(5,9); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,11); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,13); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,14); cprintf("³"); gotoxy(5,14); cprintf("³"); gotoxy(21,14); cprintf("³"); gotoxy(37,14); cprintf("³"); gotoxy(54,14); cprintf("³");gotoxy(71,14); cprintf("³");
gotoxy(5,15); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
gotoxy(5,16); cprintf("³"); gotoxy(5,16); cprintf("³"); gotoxy(21,16); cprintf("³"); gotoxy(37,16); cprintf("³"); gotoxy(54,16); cprintf("³");gotoxy(71,16); cprintf("³");
gotoxy(5,17); cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
gotoxy(5,8); cprintf("³"); gotoxy(21,8); cprintf("³"); gotoxy(37,8); cprintf("³"); gotoxy(54,8); cprintf("³"); gotoxy(71,8); cprintf("³");
gotoxy(5,10); cprintf("³"); gotoxy(21,10); cprintf("³"); gotoxy(37,10); cprintf("³"); gotoxy(54,10); cprintf("³"); gotoxy(71,10); cprintf("³");
gotoxy(5,12); cprintf("³"); gotoxy(21,12); cprintf("³"); gotoxy(37,12); cprintf("³"); gotoxy(54,12); cprintf("³"); gotoxy(71,12); cprintf("³");
gotoxy(5,6); cprintf("³"); gotoxy(21,6); cprintf("³"); gotoxy(37,6); cprintf("³"); gotoxy(54,6); cprintf("³"); gotoxy(71,6); cprintf("³");
return 0;
}
input()
{
gotoxy(15,4); textcolor(YELLOW); cprintf(" í ° í ° í M C J O-L Y B E E í ° í ° í");
textcolor(LIGHTBLUE); gotoxy(12,6); cprintf("ITEMS");
gotoxy(24,6); cprintf("UNIT PRICE");
gotoxy(38,6); cprintf("QUANTITY ORDERED");
gotoxy(60,6); cprintf("AMOUNT");
textcolor(MAGENTA);
gotoxy(5,19); cprintf("TOTAL:");
gotoxy(5,21); cprintf("VAT:");
gotoxy(5,23); cprintf("TOTAL w/ VAT:");
gotoxy(50,21); cprintf("CASH:");
gotoxy(50,23); cprintf("CHANGE:");
textcolor(GREEN);
return 0;
}
menu()
{
float c=250, ddp=310, hw=220, bpw=160, sd=60, a, v, t,m, h;
gotoxy(6,8); cprintf("Chee-C Pizza");
gotoxy(6,10); cprintf("How-I-An");
gotoxy(6,12); cprintf("Hot Wings");
gotoxy(6,14); cprintf("Baked Potato");
gotoxy(6,16); cprintf("Softdrinks (L)");
gotoxy(25,8); cprintf("P250.00");
gotoxy(25,10); cprintf("P320.00");
gotoxy(25,12); cprintf("P220.00");
gotoxy(25,14); cprintf("P160.00");
gotoxy(25,16); cprintf("P60.00");
gotoxy(46,8); cin>>c; gotoxy(58,8); a=250.00*c; printf("P%.2f",a);
gotoxy(46,10); cin>>ddp; gotoxy(58,10); a=320.00*ddp; printf("P%.2f",a);
gotoxy(46,12); cin>>hw; gotoxy(58,12); a=220.00*hw; printf("P%.2f",a);
gotoxy(46,14); cin>>bpw; gotoxy(58,14); a=160.00*bpw; printf("P%.2f",a);
gotoxy(46,16); cin>>sd; gotoxy(58,16); a=60.00*sd; printf("P%.2f",a);
return 0;
}
computation()
{
float c, ddp, hw, bpw, sd, a, v, t,m, ch, tt;
gotoxy(12,19); t=250.00*c+320.00*ddp+220.00*hw+160.00*bpw+60.00*sd; printf("P%.2f",t);
gotoxy(10,21); v=0.1*t; printf("P%.2f",v);
gotoxy(19,23); tt=t+v; printf("P%.2f",tt);
gotoxy(56,21); cout<<"P"; cin>>m;
gotoxy(57,23); ch=m-(t+v); printf("P%.2f",ch);
}
else
{
cout<<"Incorrect";
}
cin.get();
return 0;
}
#15
Re: Password C++
Posted 30 September 2012 - 10:01 AM
|
|

New Topic/Question
Reply




MultiQuote




|