this is lab for Matlab. cs 122 I need help to doing it
Lab 5: Soda Machine
CS 122L ? 15 Points Total
Building a MATLAB program using pseudo-code from your prelab
Practice with loops
Practice with ?if? statements
Before Getting started, be sure that you have downloaded the Lab5 folder and
moved it into your cs122 directory. Also, be sure to change into the cs122/Lab5
directory and addpath(?Lab5?).
Part 1: Getting the value for an entered coin
You will be building a soda machine program that takes in coins, and gives back
the appropriate change. For the first part of this lab, we will be focusing on
getting the value of a coin. Values should be represented as whole integers, not
decimals (e.g., quarter is 25, not .25).
1. Open the get_coin_value.m file.
2. Create a series of if/elseif statements that check which coin is entered,
and sets the variable value to be the correct value of the coin. The
following are the cases to consider:
If coin equals ?q?, then value equals 25
If coin equals ?d?, then value equals 10
If coin equals ?n?, then value equals 5
If coin equals ?p?, then value equals 1
Otherwise, if the coin is none of the above, add a default else
statement that sets value to 0
3. To test the code, you can run the following command in the MATLAB
You should see the number 25 pop up. To try with other coins, change the
?q? to ?d?,?n? or ?p?. Also try replacing the ?q? with ?not a coin?. A zero should
be displayed when an invalid coin is entered.
Part 2: Insert coins
For this part, you are going implement the code that asks the user to enter coins
until they have entered enough for the NAU power juice.
1. Open the insert_coins.m file.
2. Initialize total to 0. We do this because initially, no coins have been
3. Using a loop, ask the user to enter a coin until the total matches or
exceeds 95 cents. The input should be a char or string, so make sure that
you are using the ?s? with your input function (refer to the pre-lab). Also, be
sure that you store the input in a variable named coin. After the coin has
been entered, your get_coin_value function is called to get the value of the
coin and add it to the total (this has been done for you).
4. After your loop, print a message to let them know that their NAU power
juice has been dispensed.
Part 3: Give change
For this part, you are going implement the pseudo-code that you came up with in
1. Open the get_change.m file.
2. Translate your pseudo-code into working MATLAB code. Be sure that your
counter variables are named quarters, dimes, nickels, and pennies.
3. After you have finished all 3 parts, go to the command line and enter Lab5
to run your program!
Your project report (see below)
Your zipped Lab5 folder containing Lab5.m, get_change.m,
get_coin_value.m and insert_coins.m
o If you are not sure how to zip folders, please ask our TA for
Below is the point distribution for required sections in the lab report. Be sure that
each section is labeled clearly. Refer to the lab submission guidelines for details
on what goes in each section.
Submit your results in the correct place in Blackboard Learn
(http://bblearn.nau.edu) by the due date.
This question was answered on: Dec 18, 2020
Buy this answer for only: $18.50
This attachment is locked
We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy (Deadline assured. Flexible pricing. TurnItIn Report provided)
Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
About this QuestionSTATUS
Dec 18, 2020EXPERT
GET INSTANT HELP/h4>
We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.
You can also use these solutions:
- As a reference for in-depth understanding of the subject.
- As a source of ideas / reasoning for your own research (if properly referenced)
- For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
NEW ASSIGNMENT HELP?
Order New Solution. Quick Turnaround
Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.
WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN YOUR SET DEADLINE.