1 / 44

1-2-Multiple

Objective : Learn and be able to identify 1-way, 2-way, and Multiple-way sections. Find them in regular language word problems and use the best fitting to describe the solution. Post Objective : Identify how your coding up till now has either conformed or contrasted with these principles.

Download Presentation

1-2-Multiple

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objective : Learn and be able to identify 1-way, 2-way, and Multiple-way sections. Find them in regular language word problems and use the best fitting to describe the solution. Post Objective : Identify how your coding up till now has either conformed or contrasted with these principles. 1-2-Multiple Mr. Hudson Computer Science 1 Taylor_Hudson@allenisd.org

  2. Structures of a Program Programs always read Top – Down. The only line of code executed before your current line, are the ones above except for specific cases which are conditional statements skipped or functions called. And they are called in previous lines so they are effectively just removed from the structure.

  3. Conditional Statement Definition A conditional statement is a program expression that evaluates to true or false. Most conditional statements require a relational operator. All conditions must be placed inside (parentheses).

  4. If Statement Think of an if statement without an else case, this instruction gives a particular circumstance(read condition) that must be done, if and only if your condition is met. Can anyone guess the name of the selection case that the if case signifies?

  5. ONE WAY SELECTION Program Statement True Condition Program Statement False Program Statement Program Statement

  6. IF - ELSE Now lets think of an if statement with an else case, this instruction gives a particular circumstance that must be done, if and only if your condition is met, generally a block of code and if your condition is not met, you must do something else giving your program some choice. Can anyone guess the name of the selection case that the if case signifies?

  7. TWO WAY SELECTION Program Statement Condition True False Program Statement Program Statement Program Statement Program Statement

  8. IF – ELSE IF - … - ELSE This is an advanced structure. More so useful in cases where you must check multiple circumstances. With (AND)s && , and (OR)s ||. In a moment we will talk about Boolean tables. But for now, lets just introduce this as a third selection case. Can anyone guess what type of Selection case this is?

  9. Switch Case // declare variables. intmyInt; // myInt stored some number and is needed to move forward lets // assume it’s an average after our test. So the grade range could be // between 1 and 100. myInt = myInt / 10; switch(myInt){ case 9 : cout << “you got an A!”; break; case 8 : cout << “you got a B!”; break; case 7 : cout << “you got a C !”; break; case 6 : cout << “you got a D!”; break; default : cout << “you failed!”; break; }

  10. Switch case • Doesn’t handle conditions, just specific cases. • Can you guess what type of selection type this is?

  11. Multiple-Way Selection Selection Variable Match Selection Constant Program Statement No Match Match Selection Constant Program Statement No Match Match Selection Constant Program Statement No Match Program Statement

  12. Problems A program that adds all the grades given in a loop, and stores the sum of each type and the count of each, by first asking the user to enter either A if it’s a test, B if it’s a quiz, C if it’s a homework grade or E to Exit, is an example of witch type of Selection case?

  13. Problems If a student is Male he will have Mr. Brown as a PE teacher, if the student is Female she will have Mrs. Carr. The program will tell the student who their teacher is after learning the student’s name storing it with a string, age, and gender. What type of selection case is this type of program?

  14. Problems Users must input positive numbers, but we as good programmers. Know that sometimes users try to break our code, so we build something right after our cin to check and make sure the number is positive or make it so. What type of selection case is this?

  15. Problems We are creating a program to calculate our geometry homework to help tutor students. We have too first identify if the problems the students are asking are in 2 dimensions (Perimeter, distance, arc, cords, circumference, law of sine, law of cosine, etc.) or 3 dimensions (Volume, surface area, etc.) This process will take input from a user show the work and give answers. Or give instructions how to solve these problems. Can you think how you start to code this, the first thing you need to do is know which Dimension your talking about what type of selection is this case?

  16. Continued • Can you think of any other selections this case will offer?

  17. Next Time Boolean

  18. Objective : Today, we will talk about logic. Understand what logic is, and how it is prescribed. Talk about assignment that will be given Wednesday, along with correct methods of submission. Post Objective : Finish up any assignments not yet due, ask questions, and talk about logic as it is, and how CS uses it. Logic (Pitfalls) Mr. Hudson Computer Science 1 Taylor_Hudson@allenisd.org

  19. Logic P.R.H. Anonymous If you think that your paper is vacuous,Use the first-order functional calculus.It then becomes logic,And, as if by magic,The obvious is hailed as miraculous.

  20. What is Logic? Liberal Arts The Liberal Arts were divided into the Trivium “the three roads” and the Quadrivium“the four roads” The Trivium consisted of Grammar Rhetoric and Logic. The Quadrivium consisted of Arithmetic “number in itself” Geometry “number in Space” Music “number in time” and Astronomy “number in space and time”

  21. If P, then Q Truth Follows Form All men are mortal, All Greeks are men. So…

  22. Truth Follows Form All men are mortal, All Greeks are men. All Greeks are mortal! (Now try replacing Key Words)

  23. Truth Follows Form All ______ are ______, All ______ are ______. All ______ are ______! (Now try replacing Key Words)

  24. Truth Follows Form All ______ are ______, All ______ are ______. All ______ are ______! (Now try replacing Key Words) Var1 Var2 Var3 Var1 Var3 Var2

  25. Boolean OperatorsBoolean OR A T T F F B T F T F A or B T T T F

  26. Boolean OperatorsBoolean AND A T T F F B T F T F A and B T F F F

  27. Not is characterized by ~ or !

  28. Boolean OperatorsBoolean NOT Continued ~B F T F T A T T F F B T F T F ~A F F T T

  29. Truth Table #1A and (A or B) A T T F F B T F T F A or B T T T F A and (A or B) T T F F

  30. Truth Table #2(A and B) or C A T T T T F F F F B T T F F T T F F C T F T F T F T F A and B T T F F F F F F (A and B) or C T T T F T F T F

  31. Truth Table #3(A or B) and C A T T T T F F F F B T T F F T T F F C T F T F T F T F A or B T T T T T T F F (A or B) and C T F T F T F F F

  32. Truth Table Facts The truth tables of equivalent Boolean expressions are identical.

  33. Truth Table #4Is ~(A or B) = ~A or ~B ? A T T F F B T F T F A or B T T T F ~(A or B) F F F T ~A F F T T ~B F T F T ~A or ~B F T T T ^ NO ^

  34. Assume X & Y as Boolean : • Writing Code: Logical XOR (X, Y) { return ((X||Y)&&!(X&&Y)); } C = (X or Y) D = !(X&&Y) X XOR Y = C & D XOR Truth Table

  35. Boolean OperatorsBoolean XOR A T T F F B T F T F A xor B F T T F

  36. Truth Table #5Is ~(A or B) = ~A and ~B ? A T T F F B T F T F A or B T T T F ~(A or B) F F F T ~A F F T T ~B F T F T ~A and ~B F F F T ^ YES ^

  37. Truth Table #6Is ~(A and B) = ~A or ~B ? A T T F F B T F T F A and B T F F F ~(A and B) F T T T ~A F F T T ~B F T F T ~A or ~B F T T T ^ YES ^

  38. DeMorgan’s Law not(A and B) = not A or not B not(A or B) = not A and not B This says the same thing: ~(A + B) = ~A * ~B ~(A * B) = ~A + ~B

  39. If the maid did it, then it was done with a revolver only if it was done in the parlor. But if the butler is innocent, then the maid did it unless it was done in the parlor. The maid did it only if it was done with a revolver, while the butleris guilty if it did happen in the parlor. So the butler is guilty.

  40. Logical Validity and Soundness Symbolic logic is a tool or machine for identification of argument goodness. It makes sense to begin, however, not with the machine, but by saying something about the argument goodness that the machinery is supposed to identify. That is the task of this chapter. AR – an argument is some sentences, one of which (the conclusion) is taken to be supported by the remaining sentences (the premises).

  41. Consider the difference • Only citizens can vote • Herbert is a citizen • Herbert can vote • All citizens can vote • Herbert is a citizen • Herbert can vote _________________________ _________________________

  42. Is this a good characterization? Eating Brussels sprouts results in good health Ophilia has good health Ophiliahas been eating brussels sprouts

  43. How to Submit via N Drive • Step one naming a project. • Step two submit the whole project • Step three comment often and/or use descriptive and uniform variable names • Step four do your own work, it’s ok to ask for help but don’t rely on anyone to do your work for you. • Step five complete tasks on time.

More Related