Computer Science Study Guide Assignment

Computer Science Study Guide Assignment Words: 686

Variables and Expressions After a variable is declared and initialized, it can then be used in expressions into infectiousness’s =4; double delectation = infectiousness’s * 2. 5; double telescope = 100 – delectation; Statements A small piece of a program code that causes some side effects Two kinds seen so Print statement: System. Out. Print(“Hi”); Variable declaration: double radius = 7. 8; If we will need to set the value of a variable after its declaration, we must use an assignment statement. ; Method A sequence of instructions for carrying out a certain task, grouped together and given a name.

That name can be used elsewhere in the program as a stand-in for the sequence of instructions. Public static in god(into a, into b) { // instructions for Euclid algorithm Method Definition Public static return-type method name (type parameter 1){ Where a method returns an integer, return type is “into” When a method does not return a value, return type is void. The rules for method names are the same as for variables. A method can have O or more formal parameters These are the input(s) to the method Each must be specified with a data type and name Method Call A statement that causes execution of the method’s body of instructions.

Don’t waste your time!
Order your assignment!


order now

This is the “stand-in” for the assurance of instructions inside the method definition This is also where we specify the value of the formal parameters (inputs) Method Calls Nearly all examples we have seen so far simply call a method and print the returned result. into kilometers = MITOCW(105); System. Out. Print(kilometers); Method calls are expressions and can be used in other expressions. Task(105) + Amtrak(433) – Amtrak(89) Relational and Logical Operators: Operators Operand(s) Value Relational Two numerical values into, double, and other (true or false) Logical One (! Or two(&&, I l) Boolean values Boolean Expression An expression that includes relational operators and/or logical operators and evaluates to true or false. Count // Postposition: XA = returned value public static double sort(double x) {… } Together these condition form a method contract. If the preconditions are met, the method body MUST fulfill the post conditions. Method Contracts If the precondition(s) is not met, the method must still behave in a reasonable way; I. E. , not crash or give an incorrect result.

How a method handles all possible parameter values should be described in the method comment For Java built-in methods, this is described in the API (Applications Programming Interface) Scope The region in a program where the declaration of an intensifier is valid. It is not valid to use the parameters of a method outside of that methods body. Public static into sum(into a, into b){ return a + b; public static double sum(double c){ turn b + c; // error: b is out of scope Local Variable A variable declared inside a method It is also not valid to use the local variables of a method outside of that methods body.

Public static into sum(into a, into b){ Into result-?a + b; Return result; public static double sum(double c, double d){ result = c + d; // error: result out of scope return result; Scope (2) Each new structured statement defines a new scope If statements, loops, or even Just blocks via 0 Static Member Variable A variable declared inside a class with the keyword static and accessible by all Scope (3) If a parameter or local variable with the same name is used in a method, the (inner) parameter or local variable hides the (outer) static member variable.

Loop Patterns Counting Loop Accumulation loop Searching loop Optimization loop Sentinel Value A data value used to mark the end of real data. The value itself is not part of the collection of data Priming the Loop Setting things up so that the Boolean expression in a loop “makes sense” the first time it is executed Off-by-one Error An error that occurs because a loop is iterated one time too many or one time too few Loop control variable Used to regulate the number of times the body of a loop is executed.

How to cite this assignment

Choose cite format:
Computer Science Study Guide Assignment. (2022, Feb 28). Retrieved October 30, 2024, from https://anyassignment.com/samples/computer-science-study-guide-3-10407/