I wrote this little code in c++. It calculates the needed time for a given speed of a medium (for example the speed is 1024 B/s, the file size is 1MB, it'll take 17 minutes and 4 seconds to finish). The code works, but I'm not sure if it's proper.
Can you tell me if it's okay or not?
#include <iostream>
int main()
{
int transmission_speed; //speed of the transmission in bytes per seconds
int file_size_mb; //file's size in MBs
std::cout << "Enter the speed of the transmission in bytes per seconds: ";
std::cin >> transmission_speed;
std::cout << "Enter the file's size in megabytes: ";
std::cin >> file_size_mb;
int file_size_b = file_size_mb *1024*1024;
int seconds_needed = file_size_b / transmission_speed;
int days_needed = (seconds_needed / 3600) / 24;
seconds_needed -= days_needed*86400;
int hours_needed = seconds_needed / 3600;
seconds_needed -= hours_needed*3600;
std::cout << "Days needed: " << days_needed << std::endl;
std::cout << "Hours needed: " << hours_needed << std::endl;
std::cout << "Seconds needed: " << seconds_needed << std::endl;
return(0);
}
days_needed
whendays_needed
is 0. Think about that. It will make the program output cleaner if the output is not specified like in a contest or homework. \$\endgroup\$