miNi proJect!

can anyone help me with my project???
i'm trying to covert this coding into <stdio.h> only..
please..ASAP


#include<iostream>
#include<string>
using namespace std;
int main(){

float money,money1,balance,balance1;
int deposite1,withdraw,deposite;
int password,choice;
char answer;
string name="";


cout<<"Assumed your money for example"<<endl;
cin>>money1;
getline(cin,name);
money=money1;
cout<<"Your money is RM"<<money1<<endl<<endl<<endl;

cout<<"********************************\n\n"<<endl;
cout<<" Welcome to BankRupted\n\n\n";
cout<<"********************************"<<endl;

cout<<"\nPlease enter your password:"<<endl;
cin>>password;
getline(cin,name);
cout<<"Your password is valid!!\n";

do
{

cout<<"________________________________\n"<<endl;
cout<<" 1.Check your balance"<<endl;
cout<<" 2.Deposite"<<endl;
cout<<" 3.Withdraw"<<endl<<endl;
cout<<"________________________________\n"<<endl;
cout<<"Please enter your choice:\n";
cin>>choice;

switch(choice)
{

case 1:
{

cout<<"Your balance :RM"<<money1<<endl;
break;

case 2 :

cout<<"You can only deposite note RM10, RM50 and RM100"<<endl;
cout<<"Enter the amount of money to be deposite:"<<endl;
cin>>deposite1;
deposite=deposite1/10;
cout<<"Your had deposite :RM10 x "<<deposite<<endl;
balance1=deposite1+money1;
cout<<"Your balance is :RM"<<balance1<<endl;
break;

case 3:

cout<<"Enter the amount of money to be withdraw:"<<endl;
cin>>withdraw;
cout<<"Your amount is :RM"<<withdraw<<endl;
balance=money1-withdraw;
cout<<"Your balance is :RM"<<balance<<endl;

break;
}
}


cout<<"Do you want to continue(y=Yes/n=No)?"<<endl;
cin>>answer;


}while(answer=='y'||answer=='Y');


cout<<"________________________________"<<endl;
cout<<"Thank You for using our services"<<endl;
cout<<"Please come again"<<endl;
cout<<"********************************"<<endl;
return 0;

}

if there any idea to add..
i'll gladly appreciate it..
thanks a lot!!
Last edited on
You just need to use printf and scanf in place of cout and cin, and a char array in place of strings.
http://www.cplusplus.com/reference/clibrary/cstdio/printf.html
http://www.cplusplus.com/reference/clibrary/cstdio/scanf.html

I never use the cstdio, is there a safe way to use it to get a string? One that won't write past the array size
ermm.
can you give me an example???
edit my coding perhaps??
thanks a lot man!!=]
1
2
3
printf("Assumed your money for example\n");

scanf("%f",&money1);


do this way..
I tried to, but it has some problems. it doesn't seem to take the char for answer (I'm not sure why).
there is error in your program's logic, it doesn't update the balance properly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <cstdio>
using namespace std;
int main(){

float money,money1,balance,balance1;
int deposite1,withdraw,deposite;
int password,choice;
char answer, name[256];


puts("Assumed your money for example");
scanf("%f", &money1);
// scanf("%s", &name);
money=money1;
printf("Your money is RM%.*f\n\n\n",2, money1);

puts("********************************\n");
puts(" Welcome to BankRupted\n\n");
puts("********************************");

puts("\nPlease enter your password:");
scanf("%f", &password);
//scanf("%s", &name);
puts("Your password is valid!!");

do
{

puts("________________________________");
puts(" 1.Check your balance");
puts(" 2.Deposite");
puts(" 3.Withdraw\n");
puts("________________________________\n");
puts("Please enter your choice:");
scanf("%d", &choice);

switch(choice)
{

case 1:
{

printf("Your balance :RM%f.*\n", 2, money1);
break;

case 2 :

puts("You can only deposite note RM10, RM50 and RM100");
puts("Enter the amount of money to be deposite:");
scanf("%d", &deposite1);
deposite=deposite1/10;
printf("Your had deposite :RM10 x %d\n",deposite);
balance1=deposite1+money1;
printf("Your balance is :RM%.*f\n",2,  balance1);
break;

case 3:

puts("Enter the amount of money to be withdraw:");
scanf("%d", &withdraw);
printf("Your amount is :RM%d\n", withdraw);
balance=-withdraw;
printf("Your balance is :RM%d\n", balance);

break;
}
}


puts("Do you want to continue(y=Yes/n=No)?");
scanf("%c", &answer);


}while(answer=='y'||answer=='Y');


puts("________________________________");
puts("Thank You for using our services");
puts("Please come again");
puts("********************************");
return 0;

}
o00o..
you using <cstdio>
my project is about <stdio.h> only..
anyway thanks..
there's another problem..
i don't know where to put an array function..
can you help??
just to make my program looks better..>_<
cstdio is what stdio.h has been changed to for c++. stdio.h will probably work, but it might be an older on nonstandard file.
really??
thanks man!!
#include<stdio.h>
int main(){

float money,money1,balance,balance1;
int deposite1,withdraw,deposite;
int password,choice;
char answer;



printf("Assumed your money for example\n");
scanf("%f",&money1);

money=money1;
printf("Your money is RM%.2f\n",money);
printf("********************************\n");
printf(" Welcome to BankRupted\n\n\n");
printf("********************************\n");

printf("\nPlease enter your password:\n");
scanf("%f",&password);

printf("Your password is valid!!\n");

do
{


printf("________________________________\n");
printf(" 1.Check your balance\n");
printf(" 2.Deposite\n");
printf(" 3.Withdraw\n");
printf("________________________________\n");
printf("Please enter your choice:\n");
scanf("%d",&choice);

switch(choice)
{

case 1:
{

printf("Your balance :RM%.2f\n", money);
break;

case 2 :

printf("You can only deposite note RM10, RM50 and RM100\n");
printf("Enter the amount of money to be deposite:\n");
scanf("%d",&deposite1);
deposite=deposite1/10;
printf("Your had deposite :RM10 x %d\n", deposite);
balance1=deposite1+money1;
printf("Your balance is :RM%.2f\n", balance1);
break;

case 3:

printf("Enter the amount of money to be withdraw:\n");
scanf("%d",&withdraw);
printf("Your amount is :RM%d\n", withdraw);
balance=money1-withdraw;
printf("Your balance is :RM%.2f\n", balance);

break;
}
}


printf("Do you want to continue(y=Yes/n=No)?\n");
scanf("%c", &answer);

}
while (answer=='y'||answer=='Y');{



printf("________________________________\n");
printf("Thank You for using our services\n");
printf("Please come again\n");
printf("********************************\n");
return 0;
}
}

why my while loop didn't looping???
anyone please...
Topic archived. No new replies allowed.