## [solution]: During outbreak of Ebola in West Africa in 2014, many U.S.

More Details:

this is lab for Matlab. cs 122 I need help to doing it

Lab 5: Soda Machine

CS 122L ? 15 Points Total

Objectives

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

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:

a.

b.

c.

d.

e.

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

command line:

get_coin_value(?q?)

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.

1

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

entered.

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

the pre-lab!

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

Deliverables

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

assistance

2

Project Report

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.

Section

Points

1

2.Learning

Objectives

1

3.Approach

1

4.Program Inputs

0.5

5.Program Outputs

0.5

6.Program

Description

2

7.Source Code

8

8.Conclusions

Notes

1

15

total

Submit your results in the correct place in Blackboard Learn

(http://bblearn.nau.edu) by the due date.

3

Solution details:
STATUS
QUALITY
Approved

This question was answered on: Dec 18, 2020

Solution~00031148034022.zip (25.37 KB)

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)

STATUS

QUALITY

Approved

Dec 18, 2020

EXPERT

Tutor