Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

image text in transcribed

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.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

Students also viewed these Databases questions

Question

In what way does machine learning handle large datasets?

Answered: 1 week ago

Question

To solve p + 3q = 5z + tan( y - 3x)

Answered: 1 week ago

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago