Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Matlab use a menu to ask the user whether they want to predict an elongation in inches for a specified spring or spring combination

In Matlab use a menu to ask the user whether they want to predict an elongation in inches for a specified spring or spring combination given a mass OR o to predict a required mass in grams for a specified spring or spring combination given a desired elongation. If the user enters an elongation outside of 0 to 30 inches, inform them of the range restrictions and ask them again to enter an elongation until they enter a valid elongation. Similarly, if the user enters a mass outside of 0 to 2000 grams, inform them of the range restrictions and ask them again to enter a mass until they enter a valid mass. Repeat this until the user enters valid input values.

Use a menu to ask the user to indicate the configuration of springs they wish to use: individual springs, 2 springs in parallel, 2 springs in series, Sp1+Sp2 in parallel with a 3rd spring in series with that pair and Sp1+Sp2 in series with a 3rd spring in parallel with that pair. Ask the user to indicate the color of spring or springs used. The code should ask the user for only the number of springs required for the selected configuration. So, if the user selects the individual spring configuration, the code should ask for only one spring color

I need to use while loops to complete this, but I cannot get it to work. Please help. Here is my work below

clear

clc

Options={'Predict an elongation in inches [in] for a specified spring or spring combination given a mass [g]';'Predict a required mass in grams [g] for a specified spring or spring combination given a desired elongation [in]'};

UserChoice=menu('Choose an option',Options(1,1),Options(2,1));

if UserChoice==1

InputData=input('Enter a mass value between the values of 0 to 2000 grams [g]');

elseif UserChoice==2

InputData=input('Enter an elongation value between the values of 0 to 30 inches [in]');

elseif UserChoice==0

error('You did not choose an option within the menu');

end

if UserChoice==1

while InputData>0 || InputData<2000

warning('You did not enter a value between 0 to 2000');

InputData=input('Enter a mass value between the values of 0 to 2000 grams [g]');

end

end

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions