"Else If" statement, but the time frames I entered are valid. I'm not sure what I'm missing...Any help or comments are appreciated.
#include <stdio.h>
#include <conio.h>
int main()
{
float taxRate=.04;
float reg_Rate=.10;
float sixtyMinDisc=.15;
float afterHours_call=.50;
float startTime=0;
float lengthTime=0;
float grossCost=0;
float netCost=0;
printf("Hardford Telephone Company\n");
printf("\nStart Time:");
scanf("%f",&startTime);
if((startTime<0 && startTime>=2401)||(lengthTime=0))
{
printf("\nLength of Time:");
scanf("%f",&lengthTime);
grossCost=(lengthTime*reg_Rate);
printf("\nGross Cost%5.2f\n ",grossCost);
}
/* Calculating regular rate call w/ no discount */
if ((startTime >=800)&&(startTime<1800)&&(lengthTime<60))
{
netCost=(grossCost*taxRate+grossCost);
printf("\nNet Cost%5.2f",netCost);
}
/* Calculating regular rate call w/ discount */
else if ((startTime >=800)&&(startTime <1800)&&(lengthTime>60))
{
sixtyMinDisc=(grossCost*sixtyMinDisc); /*Calculating Discount*/
netCost=(grossCost-sixtyMinDisc)+(grossCost*taxRate); /*Calcualting Net Cost discounted*/
printf("\nNet Cost%5.2f\n",netCost);
}
/*Calcualting After Hours Calling */
else if ((startTime>=1800)&&(startTime<800)&&(lengthTime<60))
{
afterHours_call=(grossCost*afterHours_call);
netCost=(grossCost-afterHours_call*taxRate);
printf("Net Cost%5.2f",netCost);
}
else
printf("Invalid Data Entered");
getch ();
return 0;
}

New Topic/Question
Reply



MultiQuote





|