hi there ! im new here and i wish to stick around for a good while !!
and would like to ask you !
can u help me with this (i need this code to change a bit ! but still work in same way!! (im using c++)
plz anyone !!
#include <iostream.h>
#include <cstring.h>
string user();
string call_type();
int insert_coin();
float time(float y,string z);
int main()
{
string login;
int coin_total = 0;
float time_total;
string type;
int call1;
login = user();
if (login == "error")
{
cout << "\n\t\t\tPin tries exceeded,\n\t\tPlease consult your supervisor";
return 0;
}
else
cout << "\n\t\t\tWelcome " << login;
type = call_type();
coin_total = insert_coin();
cout << "\n\n" << coin_total;
time_total = time(coin_total,type);
cout << "\n\n\n" << login << " you have " << time_total << " for your " << type << " call";
return 0;
}
string user()
{
string n1("mary");
string n2("gerry");
string n3("sue");
string n4("jim");
string n5("clare");
string namex[5] = {n1,n2,n3,n4,n5};
string name;
int pinx[5] = {2000,3000,4000,5000,6000};
int pin;
int counter = 0;
int counter2 = 0;
string n6("error");
do
{
cout << "Please enter your name : ";
cin >> name;
cout << "Please enter your pin number : ";
cin >> pin;
while (counter <= 4)
{
if(name == namex[counter]&&pin == pinx[counter])
{
return name;
}
else
{
counter++;
}
}
if (counter2 >= 2)
{
return n6;
}
counter2++;
}while (name != namex[counter]||pin != pinx[counter]);
}
string call_type()
{
char ctype;
string c1("local");
string c2("trunk");
string c3("international");
cout << "\n";
cout << "\n\tLocal calls(L/l): 20 seconds for every 10c";
cout << "\n\tTrunk calls(T/t): 10 seconds for every 10c";
cout << "\n\tInternational calls(I/i): 5 seconds for every 10c";
while (ctype != 'l'&&ctype != 'L'&&ctype != 't'&&ctype != 'T'&&ctype != 'i'&&ctype != 'I')
{
cout << "\n\n\tPlease enter call type : ";
cin >> ctype;
}
if (ctype == 'l'||ctype == 'L')
return c1;
if (ctype == 't'||ctype == 'T')
return c2;
if (ctype == 'i'||ctype == 'I')
return c3;
}
int insert_coin()
{
float coin;
int duration;
float total = 0;
cout << "\n\tThis machine only takes 5,10,20 or 50 cent coins";
cout << "\n\t\tAny other coins will be returned";
while (coin != 0)
{
cout << "\n\n\t\tInsert Coins : ";
cin >> coin;
if (coin != 0&&coin != 5&&coin != 10&&coin != 20&& coin != 50)
{
cout << "refund : " <<coin;
total = total - coin;
}
else (coin == 5||coin == 10||coin == 20||coin == 50) ;
{
total = total + coin;
}
cout << "\t\tThe total is :" << total;
}
return total;
}
float time(float y,string z)
{
float total_time;
if (z == "local"||z == "trunk"||z == "international")
{
if (z == "local")
{
total_time = ((y/10)*20)/60;
}
if (z == "trunk")
{
total_time = (y/60);
}
if (z == "international")
{
total_time = ((y/10)*5)/60;
}
}
return total_time;
}
:( :'(
I have this as an important Assignment to do by 20/04/07!!!!!! pz help me out