• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 6 páginas
Resumen

Summary Programming Logic and Design Ch 9

Document preview thumbnail
Vista previa 2 fuera de 6 páginas

This document provides an in depth and thorough summary of chapter 9 of Programming Logic and Design. It is ready for exam and tests. Everything is laid out as it is in the textbook. All needed information is provided in short. It is written in an easy to study format and reads easy. I got distinctions in exams and tests.

Vista previa del contenido

Chapter 9

Name the parts of a method
 A program module that contains a series of statements that carry out a task
 Invoke or call a method from another program or method
 Any program can contain an unlimited number of methods
 Each method can be called an unlimited number of times
 Client- calling a program or method is called a method’s client
 A method must include:
 Method header (also called declaration or definition), includes identifying information
 Method body contains the implementation (statements that carry out the task)
 Method return statement- returns control to the calling method
 Local variables are declared in a method
 Keeping variables local helps them be more portable and less prone to error
 Global variables are known to all modules
 In scope, only recognised in a method


Design methods with no parameters
 When methods must share data
 Pass the data into and return the data out of methods,
 When you call a method from a program, you must know 4 things:
 What the method does, why are you calling the method
 Name of the called method
 Type of information to send to the method if any
 Type of return data to expect from any method if any




Design methods that require parameters
 Argument to the method- pass a data item into a method from a calling program
 Parameter to the method- method receives the data item
 When a method receives a parameter, you must provide a parameter list that includes:
 The type of parameter
 The local name for the parameter
 Signature- method’s name and parameter list
 Passed by value- copy of value is sent to method and stored in a new memory location
accessible to module
 The value remains unchanged in the main program even if it has been changed in the
module
 Each time a method executes, parameter variables listed in the method header are redeclared

,  myMethod (num myValue)
 Methods can require more than one parameter
 computerTax (num amount, num rate)
 List the arguments within the method call, separated by commas
 List a data type and local identifier for each parameter within the methods header’s
parentheses
 The data type must be repeated with each parameter
 Methods called, parameters have to be in the correct order, otherwise there will be logical
errors
 computerTax (num amount, num rate) cannot be called as computerTax (rate, amount)
 Arguments sent are called actual parameters
 Variables that accept the parameters in the method are called formal parameters


Design methods that return a value
 A variable declared within a method ceases to exist when the method ends (goes out of scope)
 To retain a value that exists when a method ends, return the value from the method back to
the calling method
 When a method returns a value, the method return type must match the data type of the value
that is returned
 Return type for a method
 Indicates the data type of the value that the method will send back
 Can be any type
 Also called a method’s type
 Listed in front of the method name when the method is defined
 Method can also return nothing
 Return type void
 Void method
 Example: num getHoursWorked (), returns numeric value
 Usually, you want to use the returned value in the calling method
 Not required Output “Hours worked is”,
 Store in variable or use directly without storing getHoursWorked ()
 Technically you are allowed to include multiple return statements in a method
 It’s not recommended
 Violates structured logic
 To use a method, you should know:
 What the method does in general
 The method’s name
 The method’s required parameters, if any
 The method’s return type, so you can use returned values appropriately
 Overhead refers to the extra resources and time required by an operation, such as calling a
method

Libro relacionado
 image
Editorial: 2023 ISBN: 9780357880876 Edición: Desconocido

Información del documento

¿Un libro?
No
¿Qué capítulos están resumidos?
9
Subido en
15 de noviembre de 2025
Número de páginas
6
Escrito en
2025/2026
Tipo
Resumen
$3.75

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
tanjanel1303
5.0
(2)
Vendido
11
Seguidores
2
Artículos
47
Última venta
1 mes hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes