Do Loop with Interest Please see speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Visual Basic Statements Chapter 5. Relational Operators  OperationSymbol  Equal  =  Less than  <  Greater than  >  Not equal   Less than.
Advertisements

Microsoft Excel. Click on “Start,” then “Microsoft Office Excel.”
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Excel Chapter 6 Review slides. How many worksheets are in a workbook, by default? three.
Integers: Multiplication & Division
1.4-5: Multiplying Integers: Basic Rules. Ways to Express multiplication Remember: All of these mean the same thing: Five times four 5 × 4 5 · 4 5(4)
Objective: Learn to multiply and divide integers.
Muffin Shop - if, calculations etc. (muffins, muffins2) Please use speaker notes for additional information!
Variables and Constants
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Break Processing Please use speaker notes for additional information!
CS0004: Introduction to Programming Variables – Strings.
CSC 162 Visual Basic I Programming. Randomizing and Formatting Randomizing Formatting –User-Defined Formats –Named Numeric Formats.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Review for Mid-term! October 26, Review Homework Worksheet True or False Operators are symbols that perform specific operations in Visual Basic.
For Loops (ProjFor1, ProjFor2, ProjFor3, ProjFor4, textbox, textbox1) Please use speaker notes for additional information!
Formatting Screen Output How do I make my numbers look pretty?
Array - adding to array at run time Please see speaker notes for additional information!
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Chapter 2 Section 5 Multiplying Integers. Multiplying Two Integers with Different Signs Words: The product of two integers with different signs. Numbers:
Objective: SWBAT Multiply and Divide Integers Fill in Planner: Practice 1-9 Agenda  Note Taking WS  Multiply and divide integers matching  Independent.
Input Textboxes Input Boxes Different than textboxes Good for small amount of input (form full of textboxes is not nice) X = Inputbox(“prompt message”,
New Project in Visual Basic Please use speaker notes for additional information!
Input and Output. Announcements  Exam Next Wednesday –Next Monday: Review session.  Invited talk: –7:30 PM,Tuesday, Oct 28th. –Prof. Katherine Socha.
Random Files Please see speaker notes for additional information!
CS0004: Introduction to Programming Project 1 – Lessons Learned.
Using Decimal Types. What are the data types that you can use? Decimal Number: Single -Is used for decimal values that will not exceed six or seven digits.
Delivery and other DO Examples Please use speaker notes for additional information!
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Two Forms Please use speaker notes for additional information!
Variable, Constants and Calculations Dr Mohammad Nabil Almunawar.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Format a Workbook Lesson 2 – Microsoft Excel 2010.
Making Multiplication Formulas on spreadsheets pg.1 1. We are adding money. So first we have to make the “D” column and the “I” column display our numbers.
Review for Final (Part 2) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Friday 5/2/2003)
Pay Example (PFirst98) Please use speaker notes for additional information!
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!
Addition Multiplication Subtraction Division. 1.If the signs are the same, add the numbers and keep the same sign = = If the.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Using a Database Access97 Please use speaker notes for additional information!
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Formatting in VB Please see speaker notes for additional information!
PERFORMING CALCULATIONS IN SCIENTIFIC NOTATION ADDITION AND SUBTRACTION.
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Using Forms and Form Elements In Visual Basic.NET.
Multiple forms - SDI & MDI Please use speaker notes for additional information!
Mealy Machines Finite State Machines with Outputs given on the transitions.
1 float Data Type Data type that can hold numbers with decimal values – e.g. 3.14, 98.6 Floats can be used to represent many values: –Money (but see warning.
Processing multiple files
Interesting Integers – Part Dos
Multiplying and Dividing Integers
Integers Rules of Operation.
Integer Rules Memorize the Rules.
Multiply and divide integers
3rd prep. – 2nd Term MOE Book Questions.
Please use speaker notes for additional information!
Variables and Arithmetic Operations
Department Array in Visual Basic
Title of Notes: Multiplying and Dividing Integers pg. 9 RS
15.
DIRECTED NUMBERS.
Multiplication and Division of Integers
Repetition - Counting and Accumulating
Subtracting integers without number line 3 digit.
Presentation transcript:

Do Loop with Interest Please see speaker notes for additional information!

Interest

Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, Tab(6); Format(wrkPrintToDate, End If Loop Until wrkToDate > txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdClear_Click() picYrAmt.Cls txtDepositor.Text = "" txtDeposit.Text = "" txtInt.Text = "" txtAnswer.Text = "" End Sub Private Sub cmdExit_Click() End End Sub Note that the DO LOOP continues until wrkToDate > Then the amount you have earned is shown in the text box. Every 7 years the amount in wrkToDate is displayed in the box. This is done using Mod 7. When the answer is evenly divisible by 7 then the information is printed.

If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, ” $##,##0.00") picYrAmt.Print Format(wrkYr, Tab(6); Format(wrkPrintToDate, End If Interest This example uses formatting with the format function: Format(expression,str) where expression is the thing to be formatted using the rules that appear in str). There are predefined format such as “Currency” which display in leading dollar format, ”, “Percent” which displays with a percent sign and the data multiplied by 100, and “General Number” which displays as is etc. You can also use symbols such as the # which simple shows a space for a digit, 0 which means that the 0 should print, $ which will show etc. means to define a string field with this many characters and fill with spaces if there are not enough. txtDeposit.Text = Format(txtDeposit.Text, "Currency")

Interest The textbox where the amount of money is displayed takes multiple lines. Note that MultiLine must be set to True.

Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do While wrkToDate < wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, Tab(6); Format(wrkPrintToDate, End If Loop txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdClear_Click() picYrAmt.Cls txtDepositor.Text = "" txtDeposit.Text = "" txtInt.Text = "" txtAnswer.Text = "" End Sub Private Sub cmdExit_Click() End End Sub Interest2

Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do While wrkToDate < wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, Tab(6); Format(wrkPrintToDate, End If Loop txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, Tab(6); Format(wrkPrintToDate, End If Loop Until wrkToDate > txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub