1. 2 3 https://en.wikipedia.org/wiki/Floating_point.

Slides:



Advertisements
Similar presentations
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Advertisements

Compound Interest.
CONTINUOUSLY COMPOUNDED INTEREST FORMULA amount at the end Principal (amount at start) annual interest rate (as a decimal) time (in years)
What is Interest? Interest is the amount earned on an investment or an account. Annually: A = P(1 + r) t P = principal amount (the initial amount you borrow.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 4 – C Program Control Outline 4.1Introduction.
 2008 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Chapter 5 - Control Structures - Part 2 Outline 5.1Introduction 5.2Essentials of Counter-Controlled Repetition 5.3The for Repetition Structure 5.4Examples.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
 2007 Pearson Education, Inc. All rights reserved C Program Control.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
Section 5.7 Compound Interest. A credit union pays interest of 4% per annum compounded quarterly on a certain savings plan. If $2000 is deposited.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 4.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Lecture 4 for loops and switch statements Essentials of Counter-Controlled Repetition Counter-controlled repetition requires  Name of control.
Thinking Mathematically
 The initialization, loop-continuation condition and increment portions of a for statement can contain arithmetic expressions.  For example,
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1 Introduction 5.2 Essentials of Counter-Controlled.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 4 C Program Control. Objectives In this chapter, you will learn: –To be able to use the for and do … while repetition statements. –To understand.
University of Palestine software engineering department Introduction to data structures Control Statements: Part 1 instructor: Tasneem Darwish.
Loop.  While Loop  Do-while Loop  For Loop Continue Statement Conclusion Loop Loop.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (for) Outline 4.1Introduction 4.2The.
 2003 Prentice Hall, Inc. All rights reserved. Outline 1 fig02_07.cpp (1 of 2) 1 // Fig. 2.7: fig02_07.cpp 2 // Class average program with counter-controlled.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 9 & 10 Repetition Statements.
Control Structures - Selections - Repetitions/iterations (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #5 Control Statements: Part 2.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
Java™ How to Program, Early Objects Version, 8/e © by Pearson Education, Inc. All Rights Reserved.
Sections 5.1 – 5.4 © Copyright by Pearson Education, Inc. All Rights Reserved.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1 Introduction 5.2 Essentials of Counter-Controlled.
Warm-ups You deposit $1000 in a savings account that yields 6% simple interest. After two years what is you account balance The balance for years 0, 1.
5.1 Introduction Problem Solving –Requires understanding of: Building blocks Program-construction principles BZUPAGES.COM.
LECTURE # 8 : REPETITION STATEMENTS By Mr. Ali Edan.
 2009 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4 – Control Structures Part 1 Outline Counter-Controlled Repetition: Example Sentinel-Controlled Repetition:
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
A DVANCED P ROGRAMMING C HAPTER 5 & 6: C ONTROL S TRUCTURES Dr Shahriar Bijani Spring 2016.
8.2 Interest Equations Key Q-How is an exponential function used to find interest? These are all money problems so you should have two decimal places.
Simple and Compound Interest Unit 4 - Investing. Determining Simple Interest I = p * r * t Interest = Principle X Rate X Time ( in years)
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
10.2 Exponential and Logarithmic Functions. Exponential Functions These functions model rapid growth or decay: # of users on the Internet 16 million (1995)
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 4 Control Statements: Part 2
Section 4.7 Compound Interest.
8.3 Compound Interest HW: (1-21 Odds, Odds)
Chapter 4 C Program Control Part I
Chapter 5- Control Structures: Part 2
Control Statements: Part 2
Control Structures: Part 2
Chapter 5- part 2 Control Statements: Loops 2
The University of Texas Rio Grande Valley
The University of Texas – Pan American
Chapter 8 JavaScript: Control Statements, Part 2
Advanced Programming Chapters 5 & 6: Control Structures
Chapter 5 Control Statements: Loops 2
Chapter 6 Control Statements: Part 2
Chapter 5.2 Vocab.
JavaScript: Control Statements II
Chapter 5 – Control Structures: Part 2
Chapter 5 Control Statements: Part 2; Logical Operators
Presentation transcript:

1

2

3

for (float i = -1; i < 1; i +=.1F) { Console.WriteLine(i); } Console.ReadKey (); 4

5

 The initialization, loop-continuation condition and increment portions of a for statement can contain arithmetic expressions.  For example, assume that x = 2 and y = 10; if x and y are not modified in the body of the loop, then the statement for ( int j = x; j <= 4 * x * y; j += y / x ) is equivalent to the statement for ( int j = 2; j <= 80; j += 5 )  If the loop-continuation condition is initially false, the app does not execute the for statement’s body. 6

7

8

9

10

11

12

13

14 The Compound Interest Equation P = C (1 + r/n) nt where P = future value C = initial deposit r = interest rate (expressed as a fraction: eg. 0.06) n = # of times per year interest in compounded t = number of years invested Simplified Compound Interest Equation When interest is only compounded once per year (n=1), the equation simplifies to: P = C (1 + r) t

App: Compound-Interest Calculations  Consider the following problem: A person invests $1,000 in a savings account yielding 5% interest, compounded yearly. Calculate and display the amount of money in the account at the end of each year for 10 years. a = p (1 + r ) n p is the original amount invested (i.e., the principal) r is the annual interest rate (use 0.05 for 5%) n is the number of years a is the amount on deposit at the end of the nth year. The app shown in Fig. 6.6 uses a loop that performs the calculation for each of the 10 years the money remains on deposit. 15

// Fig. 6.6: Interest.cs // Compound-interest calculations with for. using System; public class Interest { public static void Main( string[] args ) { decimal amount; // amount on deposit at end of each year decimal principal = 1000; // initial amount before interest double rate = 0.05; // interest rate // display headers Console.WriteLine( "Year{0,20}", "Amount on deposit" ); // calculate amount on deposit for each of ten years for ( int year = 1; year <= 10; year++ ) { // calculate new amount for specified year amount = principal * ( ( decimal ) Math.Pow( rate, year ) ); // display the year and the amount Console.WriteLine( "{0,4}{1,20:C}", year, amount ); } // end for } // end Main } 16

17

18

The initialization and increment expressions can be comma-separated lists that enable you to use multiple initialization expressions or multiple increment expressions: for (int number = 2; number <= 20; total += number, number += 2 ) { ; // empty statement } 19

 Many classes provide static methods that cannot be called on objects—they must be called using a class name. ClassName.methodName ( arguments )  Console methods Write and WriteLine are static methods.  Math.Pow(x, y) calculates the value of x raised to the yth power. 20

21

22

 The switch multiple-selection statement performs different actions based on the value of an expression.  Each action is associated with the value of a constant integral expression or a constant string expression that the expression may assume.  A switch statement determines whether each grade is the equivalent of an A, B, C, D or F. 23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50