
Concept explainers
To write:
An “if” statement that would print “Hey, you get overtime!” if the value of a variable hours is greater than 40. Test the “if” statement for values of hours less than, equal to, and greater than 40.

Answer to Problem 4.1P
Solution:
Print the statement “Hey, you get overtime!” if the value of the variable time is greater than 40.
Explanation of Solution
MATLAB Code:
clc
clear all
close all
Variable_Time_in_Hours = input('Enter Variable Time in Hours: ');
% Define the instruction to enter the variable time in hours.
if Variable_Time_in_Hours > 40
% Define the instruction to get the variable time in hours greater than 40.
fprintf('Hey, you get overtime!\n');
% Define the command to generate the statement "Hey, you get overtime!".
end
Save the MATLAB script with name, chapter4_54793_4_1P.m in the current folder. Execute the script by typing the script name at the command window to write an “if” statement that would print “Hey, you get overtime!” if the value of a variable hours is greater than 40. Test the “if” statement for values of hours less than, equal to, and greater than 40.
Result:
Therefore, print the statement “Hey, you get overtime!” if the value of the variable time is greater than 40.
Want to see more full solutions like this?
Chapter 4 Solutions
Matlab, Fourth Edition: A Practical Introduction to Programming and Problem Solving
- Don’t solve questionsarrow_forwardFred needs to choose a password for a certain website. Assume that he will choose an 8-character password, and that the legal characters are the lowercase letters a, b, c, ..., z, the uppercase letters A, B, C, ..., Z, and the numbers 0, 1, . . ., 9. (a) How many possibilities are there if he is required to have at least one lowercase letter in his password? (b) How many possibilities are there if he is required to have at least one lowercase letter and at least one uppercase letter in his password? (c) How many possibilities are there if he is required to have at least one lowercase letter, at least one uppercase letter, and at least one number in his password?arrow_forwarda =1500, b=1700 what is percentage of a is barrow_forward
- A 12-inch bar that is clamped at both ends is to be subjected to an increasing amount of stress until it snaps. Let Y = the distance from the left end at which the break occurs. Suppose Y has the following pdf. f(y) = { (a) Compute the cdf of Y. F(y) = 0 0 y -옴) 0 ≤ y ≤ 12 1- 12 y 12 Graph the cdf of Y. F(y) 1.0 0.8 0.6 0.4 0.2 y 2 6 8 10 12 F(y) F(y) F(y) 1.01 1.0ㅏ 1.0 0.8 0.6 0.4 0.2 0.8 0.8 0.6 0.4 ཨཱུ སྦེ 0.6 0.4 0.2 2 4 6 8 10 12 (b) Compute P(Y ≤ 5), P(Y > 6), and P(5 ≤ y ≤ 6). (Round your answers to three decimal places.) P(Y ≤ 5) = P(Y > 6) = P(5 ≤ y ≤ 6) = (c) Compute E(Y), E(y²), and V(Y). E(Y) = in E(Y2) v(x) = in 2 2 2 4 6 8 10 12 y 2 4 6 8 10 12arrow_forwardA restaurant serves three fixed-price dinners costing $12, $15, and $20. For a randomly selected couple dining at this restaurant, let X = the cost of the man's dinner and Y = the cost of the woman's dinner. The joint pmf of X and Y is given in the following table. p(x, y) 15 y 12 20 12 0.05 0.10 0.35 x 15 0.00 0.20 0.10 20 0.05 0.05 0.10 (a) Compute the marginal pmf of X. x 12 Px(x) Compute the marginal pmf of Y. y Pyly) 12 15 20 15 20 (b) What is the probability that the man's and the woman's dinner cost at most $15 each? (c) Are X and Y independent? Justify your answer. X and Y are independent because P(x, y) = Px(x) · Py(y). X and Y are not independent because P(x, y) =Px(x) · Pyly). X and Y are not independent because P(x, y) * Px(x) · Py(y). X and Y are independent because P(x, y) * Px(x) · Py(y). (d) What is the expected total cost, in dollars, of the dinner for the two people? $ (e) Suppose that when a couple opens fortune cookies at the conclusion of the meal, they find the…arrow_forwardLet X = the time between two successive arrivals at the drive-up window of a local bank. If X has an exponential distribution with λ = 1, (which is identical to a standard gamma distribution with α = 1), compute the following. (If necessary, round your answer to three decimal places.) (a) the expected time between two successive arrivals (b) the standard deviation of the time between successive arrivals (c) P(X ≤ 1) (d) P(2 ≤ X ≤ 4) You may need to use the appropriate table in the Appendix of Tablesarrow_forward
- Holt Mcdougal Larson Pre-algebra: Student Edition...AlgebraISBN:9780547587776Author:HOLT MCDOUGALPublisher:HOLT MCDOUGALElementary AlgebraAlgebraISBN:9780998625713Author:Lynn Marecek, MaryAnne Anthony-SmithPublisher:OpenStax - Rice UniversityAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell
- Mathematics For Machine TechnologyAdvanced MathISBN:9781337798310Author:Peterson, John.Publisher:Cengage Learning,College Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage Learning





