1 / 5

Getting Inputs Asking the USER for data

Getting Inputs Asking the USER for data. Enter username: . Velocity (m/s)? : . Enter password: . Pressure (atm)? : . Time till arrival (s)? : . Would you like to repeat (y/n)? :. The input() command. NO user-interaction. ( HARDCODING ) variable = value;

chase
Download Presentation

Getting Inputs Asking the USER for data

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Getting InputsAsking the USER for data Enter username: Velocity (m/s)? : Enter password: Pressure (atm)? : Time till arrival (s)? : Would you like to repeat (y/n)? :

  2. The input() command • NO user-interaction. (HARDCODING) variable = value; • “Prompt the user for data” = “Ask the user for data” • Allow user to enter data with the input() command • When prompting for numerical data: variable = input(‘prompt string’); Or • When prompting for char data: variable = input(‘prompt string’ ,‘s’);

  3. Key Points • Asking the user for data to process is key to any software • In MATLAB, the commandto prompt data is: input() • Two ways of prompting since primarily 2 data-types possible: var = input(‘prompt string: ’); for numerical data var= input(‘prompt string: ’, ‘s’); for char data • Ctrl+C will abort the current run

  4. Try it yourself – cont. • Using the 7 steps, create software for the following problem Pb: Calculate the volume of a hemispherical capsule, knowing the radius and the height of the middle section (see figure). These types of tanks are used in designing tanks for fuel in rockets.

  5. Vocabulary • Hardcoding • Prompt • String (review)

More Related