i have a project where i have to use several IF statements without making them nested(without using "else")
the program should asks the user to enter a file size and accepts it in float where the program should calculate the time needed to transfer the file in days,hours,minutes and seconds where the speed is 960 bytes / second.
if the file takes more than one day to be transmitted the program should display a message asking the user to reduce the file size and should charge 1$ for each 5 mins if the file takes less than one day. If the transfer takes less than 5 minutes it should display that its free of charge.
Problem: the program should only display FREE OF CHARGE if the time is less than 5 minutes. but i am getting both.
My program is as follows :
#include <iostream.h>
int main()
{
float file1; // file1 represents the file size in MB
cout << "Welcome\n\n"; //a welcome message
cout<< "Please enter the file size to be transmitted in MB:" //the program asks the user to enter the appropriate file size in MB
<<endl;
cin >> file1; //the program places the number entered by the user in file1
int day,hr,min,sec,min1,sec1,hr1; //declaring variables
sec1 = file1 / 0.00091545; /* sec1 is the total number of seconds 0.00091545 MB = 960 bytes (rounded value)
0.00091545 -------> 1sec
file1 -------> sec1?
sec1 =file1/0.00091545 */
min1 = sec1 / 60; //min1 is the total number of minutes 1 min = 60 sec
hr1 = sec1 / 3600; //hr1 is the total number of hours 1 hour = 3600 sec
day = sec1 / 86400; //day is the total number of days day = 86400 sec
min = min1 - (hr1*60); //min is the number of minutes the program should display...
sec = sec1 - ((hr1*3600)+(min*60)); //sec is the number of seconds the program should display
hr = hr1 - (day*24); //hr is the number of hours the program should display
cout <<"\n\n The time needed to transfer the file is:\n"; //a message that indicates the time needed to transfer the file
cout <<day<<"(days) "<<hr<<"(hours) "<<min<<"(minutes) "<<sec<<"(seconds) \n\n\n\n"; //the time output
if(day >= 1) //the condition needed
cout <<"Please reduce the file size"<<endl;
if(day<1) //the condition needed
cout<<"The cost of transmission is:"<<min1/5<<endl; /* 5min ------> 1$
min1 -------> ??
cost=min1/5 */
if(min1<5)
cout<<"Free Of Charge"<<endl;
return 0;
}
What do you think i should do ?
Thank you in return