hi
i am wondering if any of you guys can help me find the problem with my code. When i run it there are no errors but this if statement isn't working at all
and so i am wondering if someone can tell me what i am doing wrong full code belowCode://this is where the amount of time on the call is calculated and where the countdown begins if (type_cost==1) { for(count=sum_coins; count=0; count--) { cout<<count; Sleep(600); } } else if (type_cost==2) { for(count=sum_coins*2; count=0; count--) { cout<<count; Sleep(600); } } else if (type_cost==3) { for(count=sum_coins/4; count=0; count--) { cout<<count; Sleep(600); } } else; cout<<"Your Time is up"<<endl; system("pause"); return 0; } //this is the end of my code
Code:#include <windows.h> #include <iostream.h> char call_type; int type_cost; int coins; int accepted_coins; int sum_coins; int count; int phone_num; int main() { system("pause"); //The operning menu cout<<"========== Telephone kiosk Menu =========="<<"\n\n"<<"L – Local"<<"\n"; cout<<"T – Trunk"<<"\n"<<"I – International"<<"\n"<<"E - Exit"<<"\n"<<"======================================"<<endl; cin>>call_type; //This is where each call type is assigned a numerical value switch (call_type) { case 'T': case 't': cout<<"You have selected a Trunk Call"<<endl; type_cost=1; break; case 'L': case 'l': cout<<"You have selected a Local Call"<<endl; type_cost=2; break; case 'I': case 'i': cout<<"You have selected an International Call"<<endl; type_cost=3; break; case 'E': case 'e': cout<<"You have chosen to Exit \n Goodbye"<<endl; Sleep(1000); return 0; break; default: cout<<"Please select one of the following"<<endl<<"========== Telephone kiosk Menu =========="<<"\n\n"<<"L – Local"<<"\n"; cout<<"T – Trunk"<<"\n"<<"I – International"<<"\n"<<"E - Exit"<<"\n"<<"======================================"<<endl; } //This is the confirmation of the call type cout<<"please insert your coins now ...\n"; cout<<"You have requested "; if (type_cost==1) cout<<"a Trunk Call \n"; else if(type_cost==2) cout<<"a Local Call \n"; else if(type_cost==3) cout<<"an International Call \n"; cout<<"The charge for this type of call is "; if (type_cost==1) cout<<"10p for 10 seconds \n"; else if (type_cost==2) cout<<"10p for 20 seconds \n"; else if (type_cost==3) cout<<"10p for 4 seconds \n"; //This is the validation and addition of the coins entered cout<<"Please only enter on 5p 10p 20p 50p or 100p coins\n\n"; cout<<"Press 0 why you have finished entering coins\n"; cin>>coins; if ((coins==5)||(coins==10)||(coins==20)||(coins==50)||(coins==100)) { sum_coins=sum_coins+coins; do { cout<<"Please enter the next coin\n"; cin>>coins; if ((coins==5)||(coins==10)||(coins==20)||(coins==50)||(coins==100)) { sum_coins=sum_coins+coins; cout<<"Your total is "<<sum_coins<<endl; } else if (coins==0); else { cout<<"Please only enter on 5p 10p 20p 50p or 100p coins\n"; cin>>coins; } }while(coins !=0); } else cout<<"Please only enter on 5p 10p 20p 50p or 100p coins\n"; system("cls"); //this is where the user enters the number they with to dial and the dialing begins cout<<"Please enter the number you wish to dial\n"; cin>>phone_num; system("cls"); cout<<"Now dialing "<<phone_num<<endl; Sleep(1000); cout<<"Connected - Please start your conversation\n"; //this is where the amount of time on the call is calculated and where the countdown begins if (type_cost==1) { for(count=sum_coins; count=0; count--) { cout<<count; Sleep(600); } } else if (type_cost==2) { for(count=sum_coins*2; count=0; count--) { cout<<count; Sleep(600); } } else if (type_cost==3) { for(count=sum_coins/4; count=0; count--) { cout<<count; Sleep(600); } } else; cout<<"Your Time is up"<<endl; system("pause"); return 0; } //this is the end of my code



LinkBack URL
About LinkBacks


