Welcome! [msrickstech.weebly.com]



Syntax and Grammar(Teacher Version) Corresponding MaterialBasic Java, Lesson 2DiscussionEvery language has rules for putting together words and phrases to form well-formed sentences. These rules are known as syntax. Can you think of some rules for languages? Every language also has rules for what order words must be in. For example, in English, adjectives come before the noun they describe. We say the “purple pillow” or the “white house”. In Spanish, the adjectives come after the noun they describe. These phrases would literally be translated as “house white” or “table green”. These types of rules are called grammar. What other grammar rules can you think of?Examples of Syntax“i” before “e”, except as in neighbor or weigh.Questions end with a question mark (?).The first letter of a new sentence should be capitalized.Words that a character in a story says should have quotation marks “” around them.A dollar sign $ is used in front of a number to indicate an amount.Examples of GrammarThe subject of a sentence must come before the verb.Articles must come before the noun.Prepositions must have an object (in bold below).over the logunder the roofComputer languages also have syntax rules and grammar rules for putting together commands and functions.Class ExerciseGenerate a list of syntax rules we have learned in programming thus far with a partner. What symbols are used in programming and what are the syntax rules for using them correctly?Examples - SyntaxThe semi-colon (;) is like a period. It is used at the end of a line of code.move();turnRight();Curly braces are used to denote the body of a function or loop. There should be a left brace { to begin the body and a right brace to end it }.for(int i = 0; i < 4; i++) {move();}Parentheses () should be after a commandturnLeft();Examples - GrammarVariables must be initialized before they are used.Variables must be declared with a type as the first partdouble weight;int age;String name;Method names must come before the parametersSystem.out.println(“Parameter”)System methods must be preceded by System.out ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download