SlideShare una empresa de Scribd logo
1 de 5
Modules A module is a group of statements that exist within a program for the purpose of performing a specific task Module main() Display “How are you doing on IT104?” 	Call finalGrade() //define calling a module Display “Congratulations!” End Module Module finalGrade() Display “you’ve worked very hard” Display “Your final grade is A.” End Module
Functions With Module pp.230 Constant Real discount_percentage = 0.20 //Global constants Module main() 	Declare real regularPrice, salePrice//local variables 	Set regularPrice = getRegularPrice() 	set salePrice = regularPrice – discount (regularPrice) 	Display “The sale price is $”, salesPrice End Module Function Real getRegularPrice() 	Declare Real price Display “Enter the regular price.” Input price Return price End Function Function Real discount (real price) Return price * discount_percentage End Function A function is a module that returns a value back to the part of the program that called it
Compare /Contrast (lab 2.2) //Declare variables Declare Real stateTax Declare Real countyTax Declare Real totalTax Declare Real totalSales //Get data Display “Enter the total sales.” Input totalSales //Calculate taxes  Set stateTax = totalSales * 0.04 Set countyTax = totalSales * 0.02 Set totalTax = stateTax + countyTax //Output data Display “The total tax is”, totalTax Model main() //Declare local variables Declare Real stateTax Declare Real countyTax Declare Real totalTax Declare Real totalSales //Function calls Call inputData (totalSales)  Call calcState (totalSales) Call calcCounty (totalSales) Call calcTotal (countyTax, stateTax, totalTax) Call printData (countyTax, stateTax, totalTax) End Module
Passing Argument to Modules(Lab 2.2) Module main() //Declare local variables Declare Real stateTax Declare Real countyTax Declare Real totalTax Declare Real totalSales //Function calls Call inputData (totalSales) //passing arguments Call calcState (totalSales) Call calcCounty (totalSales) Call calcTotal (countyTax, stateTax, totalTax) Call printData (countyTax, stateTax, totalTax) End Module Module inputData (Real Ref totalSales) Display “Enter the total sales.” 	Input totalSales End Module Module calcState (Real totalSales, Real Ref stateTax) stateTax = totalSales * 0.04 End Module Module calcCounty (Real totalSales, Real Ref CountTax) countyTax = totalSales * 0.02 End Module Module calcTotal (Real countyTax, Real stateTax, Real Ref totalTax) totalTax = stateTax + countyTax End Module Module printData (Real countyTax, Real stateTax, Real totalTax) 	Display “The total tax is”, totalTax End module
Flowcharts for Modules (Lab 2.3)

Más contenido relacionado

La actualidad más candente

LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: Functions
Adam Crabtree
 

La actualidad más candente (20)

Functions in c
Functions in cFunctions in c
Functions in c
 
Function
FunctionFunction
Function
 
Cambio de bases
Cambio de basesCambio de bases
Cambio de bases
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
The Ring programming language version 1.5.1 book - Part 20 of 180
The Ring programming language version 1.5.1 book - Part 20 of 180The Ring programming language version 1.5.1 book - Part 20 of 180
The Ring programming language version 1.5.1 book - Part 20 of 180
 
Functions
FunctionsFunctions
Functions
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
Presenting things in Swift
Presenting things in SwiftPresenting things in Swift
Presenting things in Swift
 
Presentation on function
Presentation on functionPresentation on function
Presentation on function
 
Function C++
Function C++ Function C++
Function C++
 
Functions in c
Functions in cFunctions in c
Functions in c
 
User Defined Functions
User Defined FunctionsUser Defined Functions
User Defined Functions
 
C and C++ functions
C and C++ functionsC and C++ functions
C and C++ functions
 
Function in c language(defination and declaration)
Function in c language(defination and declaration)Function in c language(defination and declaration)
Function in c language(defination and declaration)
 
The Ring programming language version 1.8 book - Part 26 of 202
The Ring programming language version 1.8 book - Part 26 of 202The Ring programming language version 1.8 book - Part 26 of 202
The Ring programming language version 1.8 book - Part 26 of 202
 
Function in c
Function in cFunction in c
Function in c
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: Functions
 
Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2
 
Func up your code
Func up your codeFunc up your code
Func up your code
 
user defined function
user defined functionuser defined function
user defined function
 

Destacado

11 18 celebration (winter 2011) (nx power-lite)1
11 18 celebration (winter 2011) (nx power-lite)111 18 celebration (winter 2011) (nx power-lite)1
11 18 celebration (winter 2011) (nx power-lite)1
CAFOD
 
Primary celebration (spring 2011)
Primary celebration (spring 2011)Primary celebration (spring 2011)
Primary celebration (spring 2011)
CAFOD
 
Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...
Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...
Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...
William Kritsonis
 
Diaporama Gb5è2008
Diaporama Gb5è2008Diaporama Gb5è2008
Diaporama Gb5è2008
esam78
 
A Real Trip To England
A Real Trip To EnglandA Real Trip To England
A Real Trip To England
esam78
 
웹접근성과 보편적 접근성
웹접근성과 보편적 접근성웹접근성과 보편적 접근성
웹접근성과 보편적 접근성
Justin Shin
 

Destacado (20)

Introduction To Paid Search Dave Chaffey For Ses
Introduction To Paid Search   Dave Chaffey For SesIntroduction To Paid Search   Dave Chaffey For Ses
Introduction To Paid Search Dave Chaffey For Ses
 
웹톡스Ex 제안서 web
웹톡스Ex 제안서 web웹톡스Ex 제안서 web
웹톡스Ex 제안서 web
 
11 18 celebration (winter 2011) (nx power-lite)1
11 18 celebration (winter 2011) (nx power-lite)111 18 celebration (winter 2011) (nx power-lite)1
11 18 celebration (winter 2011) (nx power-lite)1
 
Primary celebration (spring 2011)
Primary celebration (spring 2011)Primary celebration (spring 2011)
Primary celebration (spring 2011)
 
Workshop 4011- Introdcution
Workshop 4011- IntrodcutionWorkshop 4011- Introdcution
Workshop 4011- Introdcution
 
504 Law PPT. - William Allan Kritsonis, PhD
504 Law PPT. - William Allan Kritsonis, PhD504 Law PPT. - William Allan Kritsonis, PhD
504 Law PPT. - William Allan Kritsonis, PhD
 
Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...
Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...
Ethical Decision Making In Education: Utilizing the Ways of Knowing through t...
 
Lavada Walden Ppt (Leadership) Ch 4
Lavada Walden Ppt (Leadership) Ch 4Lavada Walden Ppt (Leadership) Ch 4
Lavada Walden Ppt (Leadership) Ch 4
 
OpenStack Summit, A Community of Service Providers
OpenStack Summit, A Community of Service ProvidersOpenStack Summit, A Community of Service Providers
OpenStack Summit, A Community of Service Providers
 
CSIS 138 Javascript Class1
CSIS 138 Javascript Class1CSIS 138 Javascript Class1
CSIS 138 Javascript Class1
 
Benson Pecha Kucha
Benson Pecha KuchaBenson Pecha Kucha
Benson Pecha Kucha
 
Dr. Wm. Kritsonis, Editor, NFEAS JOURNAL, www.nationalforum.com
Dr. Wm. Kritsonis, Editor, NFEAS JOURNAL, www.nationalforum.comDr. Wm. Kritsonis, Editor, NFEAS JOURNAL, www.nationalforum.com
Dr. Wm. Kritsonis, Editor, NFEAS JOURNAL, www.nationalforum.com
 
Sahya Part 6
Sahya Part 6Sahya Part 6
Sahya Part 6
 
Diaporama Gb5è2008
Diaporama Gb5è2008Diaporama Gb5è2008
Diaporama Gb5è2008
 
C U R R I C U L U M I S S U E S & L A W
C U R R I C U L U M  I S S U E S &  L A WC U R R I C U L U M  I S S U E S &  L A W
C U R R I C U L U M I S S U E S & L A W
 
Ruby 1.9.1への道
Ruby 1.9.1への道Ruby 1.9.1への道
Ruby 1.9.1への道
 
A Real Trip To England
A Real Trip To EnglandA Real Trip To England
A Real Trip To England
 
GoodData: Introducing Insights as a Service (White Paper)
GoodData: Introducing Insights as a Service (White Paper)GoodData: Introducing Insights as a Service (White Paper)
GoodData: Introducing Insights as a Service (White Paper)
 
웹접근성과 보편적 접근성
웹접근성과 보편적 접근성웹접근성과 보편적 접근성
웹접근성과 보편적 접근성
 
Week 5 Data Types and Gottesman and Shields 1961
Week 5 Data Types and Gottesman and Shields 1961Week 5 Data Types and Gottesman and Shields 1961
Week 5 Data Types and Gottesman and Shields 1961
 

Similar a IT104 Week 4 - Module/Function

Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Mario Fusco
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
eyebolloptics
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
Taha Shakeel
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdf
indiaartz
 

Similar a IT104 Week 4 - Module/Function (20)

Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and Iterations
 
Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.
 
functions
functionsfunctions
functions
 
Practical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme ChangePractical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme Change
 
Java 102 intro to object-oriented programming in java - exercises
Java 102   intro to object-oriented programming in java - exercisesJava 102   intro to object-oriented programming in java - exercises
Java 102 intro to object-oriented programming in java - exercises
 
function_v1.ppt
function_v1.pptfunction_v1.ppt
function_v1.ppt
 
function_v1.ppt
function_v1.pptfunction_v1.ppt
function_v1.ppt
 
C++ Functions
C++ FunctionsC++ Functions
C++ Functions
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.net
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
 
Gwt and Xtend
Gwt and XtendGwt and Xtend
Gwt and Xtend
 
Joy of scala
Joy of scalaJoy of scala
Joy of scala
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdf
 
UtilityCostCalcCode
UtilityCostCalcCodeUtilityCostCalcCode
UtilityCostCalcCode
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Último (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

IT104 Week 4 - Module/Function

  • 1. Modules A module is a group of statements that exist within a program for the purpose of performing a specific task Module main() Display “How are you doing on IT104?” Call finalGrade() //define calling a module Display “Congratulations!” End Module Module finalGrade() Display “you’ve worked very hard” Display “Your final grade is A.” End Module
  • 2. Functions With Module pp.230 Constant Real discount_percentage = 0.20 //Global constants Module main() Declare real regularPrice, salePrice//local variables Set regularPrice = getRegularPrice() set salePrice = regularPrice – discount (regularPrice) Display “The sale price is $”, salesPrice End Module Function Real getRegularPrice() Declare Real price Display “Enter the regular price.” Input price Return price End Function Function Real discount (real price) Return price * discount_percentage End Function A function is a module that returns a value back to the part of the program that called it
  • 3. Compare /Contrast (lab 2.2) //Declare variables Declare Real stateTax Declare Real countyTax Declare Real totalTax Declare Real totalSales //Get data Display “Enter the total sales.” Input totalSales //Calculate taxes Set stateTax = totalSales * 0.04 Set countyTax = totalSales * 0.02 Set totalTax = stateTax + countyTax //Output data Display “The total tax is”, totalTax Model main() //Declare local variables Declare Real stateTax Declare Real countyTax Declare Real totalTax Declare Real totalSales //Function calls Call inputData (totalSales) Call calcState (totalSales) Call calcCounty (totalSales) Call calcTotal (countyTax, stateTax, totalTax) Call printData (countyTax, stateTax, totalTax) End Module
  • 4. Passing Argument to Modules(Lab 2.2) Module main() //Declare local variables Declare Real stateTax Declare Real countyTax Declare Real totalTax Declare Real totalSales //Function calls Call inputData (totalSales) //passing arguments Call calcState (totalSales) Call calcCounty (totalSales) Call calcTotal (countyTax, stateTax, totalTax) Call printData (countyTax, stateTax, totalTax) End Module Module inputData (Real Ref totalSales) Display “Enter the total sales.” Input totalSales End Module Module calcState (Real totalSales, Real Ref stateTax) stateTax = totalSales * 0.04 End Module Module calcCounty (Real totalSales, Real Ref CountTax) countyTax = totalSales * 0.02 End Module Module calcTotal (Real countyTax, Real stateTax, Real Ref totalTax) totalTax = stateTax + countyTax End Module Module printData (Real countyTax, Real stateTax, Real totalTax) Display “The total tax is”, totalTax End module