An if construct can contain further ifs and so on, this action is called nesting, and is different than elseif ladder.
The switch statement executes certain statements based on the value of a variable or expression.
Decisions, Part 2
The electricity accounts of residents in a very small town are calculated as follows:
♦ 500 units or less are used the cost is 2 cents per unit;
♦ more than 500, but not more than 1000 units are used, the cost is $10 for the first 500 units, and then 5 cents for every unit in excess of 500;
♦ if more than 1000 units are used, the cost is $35 or the first 1000 units plus 10 cents for every unit in excess of 1000;
♦ in addition, a basic service fee of $5 is charged, no matter how much electricity is used.
Write a program which enters the following five consumptions into a vector, and uses a for loop to calculate and display the total charge for each one: 200, 500, 700, 1000, 1500.
If you invest $1000 for one year at an interest rate of 12 percent, the return is $1120 at the end of the year. But if interest is compounded at the rate of 1 percent monthly (i.e. 1/12 of the annual rate), you get slightly more interest because it is compounded. Write a program which uses a for loop to compute the balance after a year of compounding interest in this way. The answer should be $1126.83. Evaluate the formula for this result separately as a check.
money = 1000;
for month = 1:12
money = money*1.01;
*These practice questions are only helpful when you work on them offline on a piece of paper and then use the solution steps function to check your answer.
Decisions, Part 2
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.
Educator.com recommends MATLAB and Simulink to use with our MATLAB course. MATLAB - Solve numerical problems quickly, so you can focus on coursework and projects rather than programming. Simulink - Model, simulate, and analyze dynamic systems. Target hardware support - Run Simulink models on Arduino, LEGO MINDSTORMS NXT, Raspberry Pi, and other hardware. 10 add-on products for math, statistics, and optimization; controls; signal and image processing; and test and measurement. The package includes a software activation key with instructions to download and install Student Version from www.mathworks.com