Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I've already written the code for the Number Guessing Game. I just need help with the code for the interactive choice between the 2 options

I've already written the code for the "Number Guessing Game". I just need help with the code for the interactive choice between the 2 options and the Euler Method problem. Thanks!
Write a MATLAB script that runs as an interactive program. Upon executing the script, the user should
be given the choice between two options detailed below. Ask the user which choice they want, then
execute the appropriate commands and display the requested output. After this is done, the user should
be asked if they want to choose again, or end the program. All of your input prompts should clearly
explain to the user what you want them to enter.
Options for program to implement:
1. Repeat the Euler method problem 1 from homework assignment 2. Ask the user to enter a
desired end time and step size, then implement an Euler finite difference method solution to
solve. Output to the user the depth value at the end time, as well as a plot showing depth over
time.
2. Number guessing game: Have the program generate a random integer between 0 and 5, without
displaying to the user. Have the user guess an integer within that range. Have the program
respond by informing them whether they need to guess higher or lower, and keep them
guessing until they enter the correct number, at which point congratulate them and tell them
they guessed the correct number.
1,Q=450,A=1250
delydt=3QAsin2(t)-QA=>34501250sin2(t)-4501250=1.08sin2(t)-0.36
y(t=0)=0
y(ti+1)=y(t1)+dydt(i)*t
t=1
i=1,t=0,y=0
1=2t: 1,y=0+(1.08sin2(1)-0.36)1=0.405
i=3,t=2,y=0.405+(1.08sin2(2)-0.36)1=0.938
i=4t=3,y=0.988+(1.08sin2(3)-0.36)1=0.599
i=5,t=4,y=0.599+(1.08sin2(4)-0.36)*1=0.858
i=6,t=5,y=0858+(1.08sin2(5)-036)1=1491
t=0.5
+,y
0.5-0.056
0.146
0.504
0.770
0.784
0.614
0.501
4,0.630
4.5,0.966
5,1.283
image text in transcribed

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

What are the key stages of WP/WIP/SWP?

Answered: 1 week ago