Question
I need help with an assignment for programming in C. The problem seems to be know as either the Jeep problem or expolaration problem. I'm
I need help with an assignment for programming in C. The problem seems to be know as either the "Jeep problem" or "expolaration problem." I'm struggling with it and could really use the help. I'm trying to use recursion and would prefer that approach. Here is the problem as it is giving to me:
I know, from speaking with the TA, that the distance for n = 2 and n = 3 is 200km. I tried writing things out but I got 250km for n = 4 instead of 253.33km. This is the function I have (the main only scans in the inputs and prints the return value of the function):
double cal_distance(int n, double cap, double rate) { double distance; if(n
} return distance; } Please help! I've tried all sorts of things in the else portion of the recursive function but I really haven't come close.
Imagine that you are stranded in the middle of a vast dessert at an abandoned gasoline station. You have a jeep and a number of large cans full of gasoline. The jeep has no gasoline in it at all and each gasoline can hold the same amount of gasoline as the tank of the jeep. The bad news is that the jeep can only carry one of the gasoline cans at a time. Your task is to write a computer program to figure out the maximum distance the jeep can travel from the abandoned gasoline station using all the gasoline in the cans. The input will be a number of data sets, one per line, in the following format: n cap rate where n (integer), oen 1,000,000, number of cans of gasoline cap (real), 0.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started