Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in MATLAB: The problem you wish to solve is, If I am at Station A and it costs $x.xx per gallon, and gas at Station

in MATLAB:

The problem you wish to solve is, If I am at Station A and it costs $x.xx per gallon, and gas at Station B is cheaper and costs $x.xx will I save money by driving x miles to Station B to get gas? Since a major goal of this assignment is to gain experience with user written functions, you are required to create a function in addition to the script file. Create a function named Cost.

Create a function file named Cost.m that:

Has two input variables: gallons and price

Calculates the cost of gas without printing any variables to the screen

Returns the cost of the gas in the variable total_cost

In the script file, perform the following tasks:

Ask the user for the number of miles their car typically travels on one gallon of gas and the number of gallons needed

Ask the user the price of gas at Station A and Station B

Calculate the cost of filling up at Station A using the function Cost()

Calculate the cost of filling up at Station B using the function Cost()

Ask the user for the distance between Station A and Station B.

Calculate the cost of driving to Station B from Station A using the function Cost()

Compare the costs of filling up at Station A with the costs of travelling to and filling up at Station B.

Display a message that indicates one of the following three options: (1) the savings for buying gas at Station B, the additional cost for buying gas at Station B, or (3) that there is no cost difference.

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

Step: 3

blur-text-image

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago