The program would take as input the amount the customer
gives and outputs how many 1 cent coins, 5 cent coins, 10 cent coins , 25 cent coins and $1 bill you need to give out.
2.88 cents
void printChange(float amountToReturn)
{
int atr = amountToReturn;
cout<<"Nos of $1 Bills : "<<atr;
amountToReturn -= ((float) atr);
atr = (amountToReturn * 100.0);
cout<<"25 Cents : "<<(atr / 25);
atr %= 25;
cout<<"10 Cents : "<<(atr / 10);
atr %= 10;
cout<<"5 Cents : "<<(atr / 5);
atr %= 5;
cout<<"1 Cents : "<<atr;
}
//Each day $10
//75 miles free per day. $0.25 per extra mile
//ChildSeat : max 2. Each $25
float CarRentAmount(int days, int miles, int childSeat)
{
float amt = 0.0;
if(days <= 0)
{
cout<<"Invalid nos of days\n";
return amt;
}
if(miles <= 0)
{
cout<<"Invalid nos of miles\n";
return amt;
}
if(childSeat < 0 || childSeat > 2)
{
cout<<"Invalid nos of children seat\n";
return amt;
}
amt = ((float) days) * 10.0;
float allowedMiles = 75.0 * ((float) days);
if(((float) miles) > allowedMiles)
amt += (((float) miles) - allowedMiles) * 0.25;
amt += ((float) childSeat) * 25.0;
cout<<"Total amount to Pay : "<<amt;
return amt;
}
-----------------------------------------------------------------------------------------------------------------
//check password, only 'm' mistakes accepted
//return 1 : code accepted
//else code not accepted
int verifyCode(char input[], char orig[], int m)
{
int miss = 0;
int len = strlen(orig);
if(strlen(input) != len)
{
cout<<"Invalid code\n";
return 0;
}
if(m < 0)
{
cout<<"Invalid mistake allowance\n";
return 0;
}
for(int i = 0;i < len;i++)
{
char origchar = orig[i];
char inpchar = input[i];
if(origchar != inpchar)
{
switch(origchar)
{
char '1' : if(inpchar != '2' && inpchar != '4') return 0;
miss++;
break;
char '2' : if(inpchar !