Traffic Codes

The assignment that I first chose to do was Make a Simple Program. In this assignment I was tasked to create a simple program, that can solve a problem. When thinking about this assignment, I want to solve a simple problem that we face everyday.

Once think about this for a couple of minute, I came up with problem I wanted to solve. I wanted to write a code that would help people figure out how long it would take you to go some amount of distance, based on just knowing the distance you were traveling and the speed at which you were traveling. I figure this is a pretty common problem (specially on college campuses) trying to budget the right amount of time to travel across campus. When I lived on campus, it was a daily thought on how early I had to leave me room in order to not be to early but also not be late.

When starting to look at this problem, I want to first start off with looking at what information I would need in order to solve the problem. I found out that I would need the distances that the user would want to travel in miles and the speed at which they would like the travel.

After getting this information, I had to think of a formula that would take in these inputs and output a time. The formula that I ended up coming up with was time = (distance traveled/ speed). This would output would give me the time I would take to travel that distance in hours.

After think about this I realized that, this program would probably be better if it told you the time in minutes. So the final formula that I came up with was: time= (distance/ speed) * 60. Giving me a final code of:

2 Replies to “Traffic Codes”

Leave a Reply

Your email address will not be published. Required fields are marked *