0

How to solve this and why?

You need to plan a road trip. You are traveling at an average speed of 40 miles an hour. Given a distance in miles as input (the code to take input is already present), output to the console the time it will take you to cover it in minutes. Sample Input: 150 Sample Output: 225

26th Jun 2022, 3:30 PM
Stefan Huzun
Stefan Huzun - avatar
3 Answers
+ 3
There is a quick arithmetic method for solving such proportions: 60 minutes - 40 miles x minutes - y miles Now you multiply diagonally and equate: 60y = 40x You are solving for x, so: x=1,5y y is your input in miles The reality is without the basic math knowledge, it will be hard for you to tackle any programming problem. My advice would be for you to focus on the maths and then try to apply your knowledge to some programming challenges.
26th Jun 2022, 4:04 PM
Nick
+ 2
So you actually just need the formula, this is something that you should figure out Tip: division and multiplication will come in handy
26th Jun 2022, 4:00 PM
Da GD Bot
Da GD Bot - avatar
+ 1
Mikolaj is correct, you need to know some math for programming. I realized it way too late 😅
26th Jun 2022, 4:05 PM
Da GD Bot
Da GD Bot - avatar