Question

A used-car dealership has hired you to modify the price of cars that are up for...

A used-car dealership has hired you to modify the price of cars that are up for sale. In a script, assign the initial information about the car to a structure called carInfo.

The structure shall have the following fields:

ID: An identification number for the vehicle

Make: A string that represents the make of the car

Year: A number that corresponds to the year of the car

Price: A number that holds the marked price of the car

Miles: The number of miles clocked

Accidents: The number of accidents the car has been in

Write a user-defined function called usedCar that receives the structure carInfo and changes each cars price depending on a number of factors.

The function should return the structure with the following adjustments to the price field.

1. Add $2,500 to the price, if the car has clocked less than 15,000 miles.

2. Reduce the price by $1,000 if it has clocked more than 190,000 miles.

3. Reduce the price by $1500 for each accident.

Run the script with the following input data set:

ID

Make

Year

Price ($)

(prior to modification)

Miles

Accidents

299

Volvo

2016

40,000

10,000

0

132

Subaru

2003

6,000

200,000

2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%function file

function carInfo = usedCar(carInfo)
if carInfo.Miles<15000
    carInfo.Price=carInfo.Price+2500;
elseif carInfo.Miles>190000
    carInfo.Price=carInfo.Price-1000;
end
carInfo.Price=carInfo.Price-1500*carInfo.Accidents;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%% SCRIPT TO RUN

carInfo(1).ID=299;
carInfo(1).Make='Volvo';
carInfo(1).Year=2016;
carInfo(1).Price=40000;
carInfo(1).Miles=10000;
carInfo(1).Accidents=0;
carInfo(2).ID=132;
carInfo(2).Make='Subaru';
carInfo(2).Year=2003;
carInfo(2).Price=6000;
carInfo(2).Miles=200000;
carInfo(2).Accidents=2;
fprintf('Car ID     Adjusted Price\n')
fprintf('=====       =====\n')
for i =1:length(carInfo)
    carInfo(i) = usedCar(carInfo(i));
    fprintf('%-5d      $%-7d\n',carInfo(i).ID,carInfo(i).Price)
end
   

Command Window >> usedcarScript Car ID Adjusted Price 299 132 $42500 $2000

Add a comment
Know the answer?
Add Answer to:
A used-car dealership has hired you to modify the price of cars that are up for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For the 100 cars on the lot of a used-car dealership, would you expect a positive...

    For the 100 cars on the lot of a used-car dealership, would you expect a positive association, negative association, or no association between each of the following pairs of variables? The age of the car and the number of miles on the odometer Opositive association Onegative association no association The age of the car and the resale value Opositive association negative association no association The age of the car and the total amount that has been spent on repairs. Opositive...

  • Colossal Company subsidiary Carz Bazaar, a new and used car dealership, hired Charles Wilson to perform...

    Colossal Company subsidiary Carz Bazaar, a new and used car dealership, hired Charles Wilson to perform various duties, such as cleaning and gassing vehicles, moving vehicles from one lot to another, and maintaining the showroom and vehicle lots. In this position, Wilson had access to keys to the vehicles through a key-control procedure. Under this procedure, an attendant keeps the keys in a control shack. When any employee wants to move a company vehicle, the attendant inputs information into a...

  • 2 Onwa Motors sacar dealership that has two types of operation car sales and service. The...

    2 Onwa Motors sacar dealership that has two types of operation car sales and service. The two divisions operate independently and at the showroom for car r y rate on the service shop (They are oss the s tomach other Despite the independence of the divisions, the company provides incentives to its to som e packages song with the sale of cars now and used Condor the following offer posted one of the windows Click the icon to view the...

  • Java - Car Dealership Hey, so i am having a little trouble with my code, so...

    Java - Car Dealership Hey, so i am having a little trouble with my code, so in my dealer class each of the setName for the salesman have errors and im not sure why. Any and all help is greatly appreciated. package app5; import java.util.Scanner; class Salesman { private int ID; private String name; private double commRate; private double totalComm; private int numberOfSales; } class Car { static int count = 0; public String year; public String model; public String...

  • c++ problem You are asked to implement a car ordering system for Bobcats Auto Dealership. This...

    c++ problem You are asked to implement a car ordering system for Bobcats Auto Dealership. This dealership is brand new and only sells one brand of cars with three different models. However, a buyer can add options if they choose. Write a C++ program that allows the user to order a single car with different options. All the options available will be stored in a file called "options.txt" along with their cost. You may assume that the file will not...

  • Zipcar: “It’s Not About Cars—It’s About Urban Life” Imagine a world in which no one owns...

    Zipcar: “It’s Not About Cars—It’s About Urban Life” Imagine a world in which no one owns a car. Cars would still exist, but rather than owning cars, people would just share them. Sounds crazy, right? But Scott Griffith, CEO of Zipcar, the world’s largest car-share company, paints a picture of just such an imaginary world. And he has nearly 800,000 passionate customers—or Zipsters, as they are called—who will back him up. Zipcar specializes in renting out cars by the hour...

  • You have recently been hired by Swan Motors, Inc. (SMI), in its relatively new treasury management...

    You have recently been hired by Swan Motors, Inc. (SMI), in its relatively new treasury management department. SMI was founded 8 years ago by Joe Swan. Joe found a method to manufacture a cheaper battery with much greater energy density than was previously possible, giving a car powered by the battery a range of 700 miles before requiring a charge. The cars manufactured by SMI are midsized and carry a price that allows the company to compete with other mainstream...

  • Question: Analyze and evaluate the existing corporate strategy and structure at Fortune Motors. FORTUNE MOTORS (TAIWAN):...

    Question: Analyze and evaluate the existing corporate strategy and structure at Fortune Motors. FORTUNE MOTORS (TAIWAN): IMPLEMENTING STRATEGY CHANGE USING THE BALANCED SCORECARD Jung Hua Li, chief executive officer (CEO) of Fortune Motors, the largest Mitsubishi dealership in Taiwan, sat in his office in eastern Taipei on a chilly day in January 2004, thinking carefully about his vision for the survival of his company. He knew that Fortune Motors’ sales in 2003 had fallen below 50,000 units for the first...

  • Please help me answer theses practice questions QUESTION 2 Which of the following can a country...

    Please help me answer theses practice questions QUESTION 2 Which of the following can a country implement to protect local industries (e.g. bicycles) according to the video on the deceptive promise of free trade? Border walls local training programs to strengthen local industries protectionist policies such as tarrifs creating a high minimum wage locally governments can't do anything QUESTION 3 Which of the following European countries has a trade surpluse with the US as well as most other European countries...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT