Search Results - PATH Pascal (Computer program language)
-
1
Authors: et al.
Source: Computer Networks. Jan2011, Vol. 55 Issue 1, p241-263. 23p.
-
2
Authors: et al.
Source: Acta Veterinaria Brno. 2025, Vol. 94 Issue 4, p297-306. 12p.
Subjects: Semen analysis, Reproductive technology, Computer-aided engineering, Animal breeding, Livestock productivity, Sperm motility, Cryopreservation of cells, Portable computers
PDF Full Text -
3
Alternate Title: Julio Pompa Frizza: Diseñando el Éxito.
Authors: CORTEZ, MARIO A.
Source: La Prensa San Diego. 3/17/2017, Vol. 41 Issue 11, p1-9. 4p.
-
4
Authors:
Source: Annals of the New York Academy of Sciences [Ann N Y Acad Sci] 2025 Dec 16. Date of Electronic Publication: 2025 Dec 16.
Publication Type: Journal Article; Review
Journal Info: Publisher: New York Academy of Sciences Country of Publication: United States NLM ID: 7506858 Publication Model: Print-Electronic Cited Medium: Internet ISSN: 1749-6632 (Electronic) Linking ISSN: 00778923 NLM ISO Abbreviation: Ann N Y Acad Sci Subsets: MEDLINE
-
5
Authors:
Subject Terms: Pathos, Path Pascal (Computer program language)
File Description: con
Relation: PATHOS, a Path Pascal operating system.; http://hdl.handle.net/2027/uiuo.ark:/13960/t9184w717
Availability: http://hdl.handle.net/2027/uiuo.ark:/13960/t9184w717
-
6
Authors:
Subject Terms: PATH PASCAL (Computer program language)
File Description: con
Availability: http://hdl.handle.net/2027/uiuo.ark:/13960/t48p7k01f
-
7
Authors:
Source: Principles & Practice of Constraint Programming - CP 2005. 2005, p358-372. 15p.
-
8
Authors: et al.
Source: Practical Aspects of Declarative Languages (9783540309475). 2005, p73-87. 15p.
-
9
Authors:
Subject Terms: Real-time data processing, PATH PASCAL (Computer program language), Fault-tolerant computing
File Description: con
Relation: http://hdl.handle.net/2027/uiuo.ark:/13960/t64471n4k; http://hdl.handle.net/2027/uiug.30112121952599
-
10
Authors:
Subject Terms: Pascal (Computer program language), Operating systems (Computers), Real-time data processing
File Description: con
Relation: http://hdl.handle.net/2027/uiuo.ark:/13960/t14n0r690; http://hdl.handle.net/2027/uiug.30112121956319
-
11
Authors:
Resource Type: eBook.
Subjects: Python (Computer program language), Computer graphics--Computer programs, Computer graphics--Mathematics
Categories: COMPUTERS / Software Development & Engineering / Computer Graphics, COMPUTERS / Programming / Games, COMPUTERS / Computer Science, COMPUTERS / Programming / General, COMPUTERS / Languages / Python, COMPUTERS / Programming / Open Source
PDF Full Text -
12
Authors:
Subject Terms: Ada (Computer program language), Computer programming -- Study and teaching (Higher), technical reports
File Description: application/pdf
Relation: Technical report (University of Alabama at Birmingham. Department of Electrical and Computer Engineering); 2018-07-ECE-022; Technical report (Southern Methodist University. Department of Computer Science and Engineering); 88-CSE-16; Technical Report 2018-07-ECE-022 Technical Report 88-CSE-16 This technical report is a reissue of a technical report issued March 1988 Department of Electrical and Computer Engineering University of Alabama at Birmingham July 2018 --- ~-~---~-~ Technical Report 88-CSE-16 AN ADA COURSEWARE Murat M. Tanik Southern Methodist University Udo W. Pooch Texas A&M University Department of Computer Science and Engineering Southern Methodist University Dallas, Texas 75275-0122 March 1988 AN ADA COURSEWARE Section J. : I.I. I.II. I. III. I.IV. Section II : II.I. II. II. Introduction and Overview Introduction overview Syllabus Bibliography Course plans Student lesson plans Lessons Appendix 1 Appendix 2 Appendix 3 1-33. Daily Labs. Problem Solving Methodology. Documentation Standards. Instructor lesson plans Lessons : 1-33. Section III : Lab activities III.I. Daily labs III.II. Exercises Overview of Exercise 1 Exercise 2 Exercise 3 computer exercises Spaceship Docking Simulation. Reports for Air Support. Modification of Exercise 2. III.III. Lesson by lesson program listings Section IV ~ Other programs IV.I. Janus Ada examples IV.II. Projects Project 1 Project 2 Multiprogramming Simulation Real-Time Switch IV.III . Classic programs Dining philosophers Game of life 1 SECTION I Introduction and overview 2 I.I Introduction Early research on developing self-paced courses have identified features such as: 1. individually paced, 2. mastery-oriented, 3. use of study guides for communication of information, and 4. lectures for the purpose of stimulation and motivation [ 4, 5] . In developing this computer-aided Ada course we included most of these features. In addition, we used ACM Curriculum recommendations as a course development guideline. The objectives stated in the ACM recommendation can be -summarized as follows: 1 . To introduce a disciplined approach to problem solving methods and algorithm development: One of the most fundamental CS1 objectives is that of problem solving. ACM suggests teaching such problem solving methods as the problem decomposition strategy, solution by analogy, sQlving a special case of a general problem, and conversely, generalizing a specific solution. A student must be taught to analyze a problem by first understanding it, and then specifying input data and output requirements. 2. To introduce procedural and data abstraction: Along with problem solving, algorithm development needs to be thoroughly discussed. This should include the use of pseudo-code and pictorial descriptions in representing algorithms, and desk checking and test data used in the verification of algorithms. Students should be taught the importance of procedural and data abstraction. Extensive use of subprograms must be encouraged in student programming assignments. Various concepts relating to subprograms, such as procedures and functions, parameters and identifiers, subprogram nesting and recursion must be introduced. In addition, sequential, iterative, and conditional control structures must be taught. The introduction of various primitive data types and their relational operators, along with structured data types, will help the student to employ data abstraction in their programs. 3. To teach program design, coding, debugging and testing, and documentation using good programming style: The ACM divides program development into four areas, the first being that of design. A good program will start with top-down design and stepwise refinement, and employ procedural and data abstraction, and information hiding. The next area is coding, which includes the use of structured control statements and good programming style. Program correctness is another element in development. The student must learn to generate test data, along with the use of output statements, stubs, and drivers to help in debugging. Lastly, documentation techniques must be addressed. 3 4. To teach a block-structured high-level programming language: The programming language taught in the CSl course is an important concern. It must be one that can allow a student to use what is learned during the CSl course. It should be a blockstructured high-level language with such features as structured control statements, structured data types, strong data typing, subprograms with parameters, dynamic storage allocation, and recursion. Typical languages include Pascal, PL/I, and Ada. 5. To provide a familiarity with the evolution of computer hardware and software technology: Another important subject area is that of the development of computer hardware and software technology. This includes the history of programming languages, from machine to assembly to high-level languages, and the translation of these high-level languages. The internal representation of data types is also covered. 6. To provide a foundation for further studies. in computer science: The ACM also lists advanced topics that may be introduced in the CSl course. Their coverage depends on both the students and the teacher. These topics include advanced data structures, searching and sorting algorithms, the analysis of algorithms, and program verification with loop invariants. This Ada courseware is designed with the above objectives in mind. Programming is introduced as a means of solving the problems and implementing the algorithms with great attention paid to good program design, coding, debugging, and testing, as well as programming style and documentation. As the course name indicates, Ada is used as the programming language. This provides us with a suitable tool to teach procedural and block-structured programming, and introduce data abstractions. In addition, the course covers an overview of computer hardware and software technologies. Computer hardware components and their functionality are studied; operating system concepts are introduced; and other system software such as editors and compilers are presented. CSl students are expected to have been exposed to computers and programming before. A strong mathematics background is highly desirable [ 6] . In order to support analysis of algorithms presented in CSl, the students are recommended to take a discrete mathematics course. A four credit hour CSl course should include one or two hours of laboratory time. The laboratory time will be essential to the smooth running of the CSl class. students will learn the proper use of available computer resources. Quizzes can be given, along with other material to complement the lecture class. Students will be helped with their programming assignments to the extent that programming tools are taught. Additional time will have to be spent by the student to complete programming assignments. The Ada-centered courseware includes a complete set of programming assignments, daily labs, and instructor directions 4 [1]. As suggested, assignments start out short and relatively simple, and become longer and more complex as new concepts are introduced, and the student becomes comfortable with the programming environment. The computer facilities available must support the programming assignments and labs. These resources should be in an interactive programming environment, such as that found with a time-shared main-frame or minicomputer, or a personal computer. This courseware has been developed for use on a personal computer with an Ada compiler or it can be used on larger systems, such as a Vax 11/780. course Administration Highlights A student taking this course discovers that the coursework is divided into 4 2 units. The content of the units correspond to conceptual chunks in programming languages and Ada, and are consistent with ACM Curriculum 1984. At the start of the course, students receive a study guide and course syllabus to direct the work on the first unit. When we administered the course, we either used printed guides or directed the students to computer terminals which included necessary documents in their accounts. Before progressing into the next unit in the course sequence, students demonstrate their mastery of the current unit in the laboratory by performing the necessary work. We experimented in teaching Ada using this courseware in academic environments and our course formats reflect this experience. However, the approach we have taken is adaptable for teaching professionals as well. In teaching a course such as this for industrial audience, the emphasis should be put on the lab activities and self-paced nature of the course. The industry professionals are expected to have the required maturity and motivation to successfully complete the course on their own with minimal guidance from the instructor. The lab activities are more useful for these professionals in order to emphasize the practical side of this course. Course Subject Area Highlights The first three lessons are introductory in nature. They include such topics as the objectives of CS1, the operating system, the editor, the development and function of computer hardware, the history of Ada, and the difference between compiling, linking and running a program. The Daily Labs that accompany these lessons allow the student to become familiar with a computer and the use of an editor. In addition, they are taught how to compile, link and run a sample Ada program. The next set of lessons, up to the first test, 5 introduce many important concepts. These include: top-down design with stepwise refinement, reserved words, identifiers, commenting, subprograms, the writing and use of an Ada Package, variables, data types, parameters, and the first control structures. The daily labs accompanying these lessons include programming assignments that use the introduced ideas including the creation of an Ada package to be re-used throughout the duration of the course. The following lessons address problem solving and the use of control structures in depth. They also look at documentation, structured programming, top-down design, pseudo-code, algorithms, functions, and recursion. During these Lessons, the students begin working on the first major project called Computer Exercise #1. The appendix presents an example of a program cove~d in Lesson #13. It concentrates on control structures. • f+J Next · we focus on constants, ranges, types, one and ~wo dimensional arrays, searching and sorting, debugging, and the use of external data files. Students begin the second project (Computer Exercise #2) during this set of lessons. The remaining portion of the course focuses on the completion of all exercises and any literary items that have not already been covered. A list of literary items at the end provide guidelines on topics to be included. These are the history of computers, major hardware components, system software, evolution of programming languages, translation of high-level languages, internal data representation, major languages and their uses, security and privacy, data communications and networking, and microcomputers. Course Format Although it is most important to cover the right subjects in the courseware, the format of the course plays an important role in successfully meeting the objectives. We feel that the format of this courseware is one that will allow students to fully grasp the concepts taught and it is consistent with our objectives stated earlier. The courseware starts out with a syllabus. This lists the lesson number, topics to be discussed during the lectures, and the labs to be used with the laboratory section of the class. The course is designed so that one lecture period and one laboratory period comprising one lesson. There are 42 lessons in the course. - , Lesson plans are distributed among the students in order Yo provide a guideline of the material to be covered. The lesson plans include daily lab information to be completed with each lesson and contain a set of useful appendices. In the courseware manual, there are instructions for copying the daily lab, and the manner of using it to prepare for the next class or lab. In addition a problem solving 6 methodology is described in the courseware manual. It leads the student step-by-step starting with the student starting the problem in his own words and dividing the problem into smaller sub-problems, all the way to the coding. The daily labs are designed to reinforce concepts that have been taught in class, while teaching the student problem solving and programming. The labs start out instructing the student in the use of the editor and operating system. However, they become progressively more difficult as the student becomes better acquainted with programming and the programming environment. This is accomplished by giving less and less of the problem solution, until the latter section of the labs when the student is given only the problem statement. This approach allows the students to become confident with the programming environment by allowing them to be successful in their attempts from the beginning. The daily labs are administered in a four-step process. First, the student copies the lab and the approved solution from a master diskette or file directory before the class meets. During class, the instructor presents the lesson, and the student is allowed to ask questions about the lecture. The students then run a copy of the approved solution of the lab to see the correct output format and observe that the daily lab can be done. The students proceed from that point on with the lab during the remainder of the laboratory period on their own. Programming projects are assigned after the daily labs have been completed. The projects are designed to make students synthesize the concepts they have learned in a block of lessons. The student is given an objective and a complete problem statement for each project exercise. The problem statement includes a complete background, requirements, and extensions to make the project more challenging. Each student also has access to an executable object file for the assignment that the student can run to see what the actual output should look like. Future Improvements and the Use of an Intelligent Help system We feel that an incremental project-oriented courseware designed around Ada is one of the best ways to meet requirements for a CSl course described by the ACM Curriculum Committee Task Force of 1984. Ada not only provides the language constructs needed to teach this course, but also emphasizes the need for code reusability. Ada also allows tasking, real-time programming, simulation, and scientific calculations, making it usable throughout a student's computer education. 7 In addition, the Ada language is completely standardized. Students can learn Ada, and know that they will not have to learn different versions of it when it is implemented on different machines. The success of this incremental Ada based programming course will increase at least an order of magnitude if an intelligent help system is provided in the background to support students' needs for domain-specific knowledge. This automatic help system provides us the means to implement Keller's teaching plan [4], (individually paced, mastery-oriented approach) in our courseware. There is a widening gap between the novice students and the sophisticated operating systems and Ada support environments. Because of this gap, the students, who are simply attempting to run a specific program, get frustrated and discouraged. The problem of interfacing with novice users usually demands more intelligence and friendliness from the system. Research is in progress [7] to provide intelligent assistance for novice and expert users of this courseware. This intelligent help system is to be similar in concept to the one developed by D. Yun [2] for the IBM CMS operating system. conclusion over 200 pages of course material has been developed and class-tested for three years at Texas A&M, the University of Texas at Dallas, and Southern Methodist University. It has been our experience that this package helps to take some of the load off the instructor, allows students to go at their own pace, and enables students to get on-line help on their own. As universities and industry switch to Ada, this kind of a computeraided approach in teaching the Ada language and concepts can help make the transition from other languages much smoother. Acknowledgements Some of the early research in developing this courseware was performed by U. Pooch and s. Teel at Texas A&M University. Later improvements were done by U. Pooch and M.M. Tanik at University of Texas at Dallas. Augmenting the courseware with an intelligent help system was suggested by D. Y. Y. Yun. Work at Southern Methodist was done with the assistance of K. Burns and J. Abuzaid. References [1] M. M. Tanik, U. Pooch, Ada Courseware Manual, Unpublished work, 1986. 8 [2] E.B. Koffman, Curriculum for CS1, oct. 1984. P.L. Miller, and C.E. Wardle, "Recommended 1984, 11 Communications of the ACM, Vol 27, [ 3 ] D. Y . Y . Yun, D. Loeb, "The CMS - HELP Expert System, " Proceedings of the International Conference on Data Engineering, 1984. [4] J.A. Kulik, c. Kulik, and K. Carmichael, "The Keller Plan in Science Teaching," Science, Feb. 1974, pp. 379-383. [5] R.M. White, D. Fessel, "A Self-Paced Course in Introductory Computer Programming," IEEE Trans. on Education, Nov 1975. [6] A. Ralston, "The First Course in Computer Science Needs a Mathematics Co-requisite," Communications of the ACM, Vol 27, No. 10, Oct 1984. [7] Y. Liqun, M.M. Tanik, D.Y.Y. Yun, "Automated Help with Perspectives in a Rapid Prototyping Environment," working paper, Southern Methodist University, 1987. [8] G. Lapalme, P. Chartray, "An Educational System for the Study Tasking in Ada," IEEE Transactions on Education, Vol. 30, No. 3, August 1987. Appendix The objective of Lab 13 is to get the student acquainted with the following: [1] Be able to declare and use FLOAT AND BOOLEAN -variables. [2] Understand the assignment statement. [3] Learn how to convert the value in a variable of type INTEGER into a value of type FLOAT. [4] Learn the arithmetic operators REM and MOD, and their characteristics. [5] Be able to instantiate a new FLOAT_IO package for the predefined type FLOAT, and input and output FLOAT's in a readable form using field widths. (6] Use some control structures such as the IF statement . with TEXT IO, CS100; procedure-LAB 13 is use TEXT_IO, CS100; Lesson 13 Program : 9 -MOD for VERDIX use FLOAT_IO; -package REAL_IO is new FLOAT IO ( FLOAT ); use REAL_IO; -main procedure variables TEST_SCORE, MAX_SCORE, PERCENTAGE CONTINUE CALC : boolean; float; - Procedure READ SCORES -reads in a maximum possible- - score and actual test score. Checks for validity. - Tasks: 1. Prompt and read the maximum possible score. - 2. Prompt and read the actual test score. 3. If actual test score not between 0 and max -Print out the test score -Print out an error message -Set a stop flag to be passed back to invoking procedure. 4. Pass the max and test score, along with the - stop flag back to the invoking procedure. procedure READ SCORES ( ACTUAL_SCORE, MAX SCORE: out float; CONTINUE CALC : out boolean ) is MAX, TEST SCORE : float; begin - READ_SCORES CONTINUE_CALC := TRUE; put (standard output,"Please input the maximum score on the test:"); get (standard_input, MAX ); possible MAX SCORE := MAX; new=line (standard_output); r. put (standard output,"Please input the student's score on - this test:"); get (standard_input, TEST_SCORE); if (TEST SCORE > MAX ) OR (TEST SCORE < 0.0) then put (standard_output,"The score you input"); put (standard_output, TEST_SCORE, 6, 2, 0); put (standard output,"was not in the range of 0 to "); put (standard=output, MAX, 6, 2, O); CONTINUE CALC := FALSE; end if; - ACTUAL SCORE := TEST_SCORE; end READ_SCORES; Procedure FIND PERCENTAGE- finds the percentage. 10 procedure FIND- PERCENTAGE(TEST- SCORE,MAX - SCORE:in float; PERCENTAGE : out float ) is begin - FIND_PERCENTAGE PERCENTAGE := (TEST_SCORE / MAX SCORE) * 100.0; end FIND_PERCENTAGE; - Procedure PRINT INFORMATION- prints the max score,test score, and percentage. Then finds the lettergrade and prints this out. procedure PRINT INFORMATION ( TEST_SCORE,MAX_SCORE, PERCENTAGE : in float) is begin - PRINT_INFORMATION new line (standard_output); put-line (standard_output,"Max Score Test Score Grade"); put line (standard_output," --- --- --- "); put (standard output, MAX SCORE, 6, 1, 0); put (standard=output, TEST_SCORE, 11, 1, 0); put (standard output, PERCENTAGE, 13, 2, 0): put (standard output," "); if PERCENTAGE->= 90.0 then put (standard output, "A"); elsif PERCENTAGE->= 80.0 then put (standard output,"B"); elsif PERCENTAGE->= 70.0 then put (standard output,"C"); elsif PERCENTAGE->= 60.0 then put (standard_output,"D"); else put (standard_output,"F"); end if; new line (standard output); new-line (standard output); new-line (standard output); end PRINT INFORMATION; LAB 13 - Main Execution Block 11 Percentage begin --LAB_13 PRINT_COVER_SHEET; READ_SCORES ( TEST_SCORE, MAX_SCORE, CONTINUE CALC}; if CONTINUE CALC then FIND_PERCENTAGE ( TEST_SCORE, MAX_SCORE, PERCENTAGE); PRINT INFORMATION ( TEST_SCORE, MAX_SCORE, PERCENTAGE}; end if; end LAB 13 This program reads in a maximum possible score on a test and then an actual test score. It will check the score to insure it is a valid score between o and the max possible score. If the score is invalid, an appropriate error message will be given. If the score is valid, then the program calculates the test J percentage and print out the raw score, the maximum possible points, the percentage, and a grade. The grade will be based on the table below: Percentage >=90 =80 =70 =60 , the Operating System and the EditoJ Lab: Use of the Editor 3. Introduction to Ada Lab: LAB3.STU 4. Introduction to an Ada Program Lab: LAB4.STU 5. Writing and Using an Ada Package Lab: LAB5.STU 6. Declaring, Using and Writing Variables Lab: LAB6.STU 7. Subprograms with IN Parameters Lab: LAB7.STU 8. GET and Subprograms with IN OUT and OUT Parameters Lab: LAB8.STU 9. Selection Lab: LAB9.STU 10. CASE statement and Logical Operators Lab: LAB1 0 . STU 11. Exam #1 12. Problem Solving Formalized Lab: Finish any unfinished Daily Labs 13. FLOAT and BOOLEAN Variables Lab: LAB13.STU 14. WHILE Loops and the "Trailer" Technique Lab: LAB14.STU 15. Computer Exercise #1 (due Lesson 24) Lab: Computer Exercise #1 16. FOR Loops and the "Header Technique" Lab: Computer Exercise #1 17. Literacy Lab: Computer Exercise #1 18. Algorithms Lab: Computer Exercise #1 18 19 . Functions Lab: LAB19.STU and Computer Exercise #1 20. Exam #2 21. Constants,Types,Subranges,Subtypes, and One-Dimensional Arrays Lab: Computer Exercise #1 22. Review of Functions, Types, Subranges, Subtypes, Constants and One-Dimensional Arrays Lab: Computer Exercise #1 23. Searching Lab: Computer Exercise #1 24. Sorting Lab: Computer Exercise #1 Computer Exercise #1 due 25. Computer Exercise #2 (due Lesson 32) Lab: Computer Exercise #2 26. Review of Sorting and Searching Lab: Computer Exercise #2 27. Two-Dimensional Arrays and Variables of type STRING Lab: Computer Exercise #2 28. Reading from External Data Files Lab: Computer Exercise #2 29. Records and Writing to External Files Lab: Computer Exercise #2 30. Recursion and Sets Lab: Computer Exercise #2 31. Ada Review Lab: Computer Exercise #2 32. Exam #3 Computer Exercise #2 due 33. Computer Exercise #3 Lab: Computer Exercise #3 (due Lesson 36) 34 - 42 ==> Completion of all Exercises 19 I.IV. BIBLIOGRAPHY Augenstein, M., Tenenbaum, Primary Programming Language PL/1, Pascal, and Ada," ACCM 1983) 1 148-153 • A., and Weiss, G. "Selecting a for a Computer Science Curriculum: SIGCSE Bulletin, Vol 15, No 1 (Feb. Barnes, J.G.P. Programming in Ada. Company, London, 1984. Addison-Wesley Publishing Brandon, Clark. (course notes) . 11 1984. "Introductory Ada nad Computer Programming Vermont Technical College, Randolph Center, VT, Booch, Grady. Software Engineering with Ada. The Benjamin/Cummings Publishing Company, Inc., Menlo Park, CA, 1983. Capron, H.L. and Williams, B.K. Computers and. Data Processing. The Benjamin/Cummings Publishing Company, Inc., Menlo Park, CA, 1984. Grier, Sam. Pascal for the Eighties. Department of Computer Science, U.S. Air Force Academy, CO, 1982. Herrington, David E. "Special Topics in Ada (course notes)." Department of Computer Science, u.s. Air Force Academy, co, 1984. Koffman, Elliot P., Miller, Phillip L., and Wardle, Caroline E. "Recommended curriculum for CS1, 198411 • CACM, Vol 27, No 10 (Oct. 1984), 998-1001. Military 1815A). Standard Ada Programming Language (ANSI/MIL-STDDepartment of Defense, Washington, D.C., 1983. Price, David. Introduction to Ada. Prentice-Hall, Inc., Englewood Cliffs, NJ, 1984. Sincovec, Richard and Wiener, Richard. Programming in Ada. John Wiley and Sons, New York, NY, 1983. [ Smith, David A. "ANSI Standard Ada --Quick Reference Sheet." Ada Letters, Vol IV, No 1 (July-August 1984), 61-66. Teel, Scott c. "Introduction to Computer Science (course notes)." Department of Computer Science, U.S. Air Force Academy, co, 1984. Wirth, Niklaus. "Program Development by Stepwise Refinement". CACM, Vol 26, No 1 (Jan. 1983), 70-74. 20 SECTION II - Course Plans II.I Student Lesson Plans 21 STUDENT LESSON PLANS LESSON 1 TITLE: Introduction to CS1 SPECIFIC OBJECTIVES: Note: This lesson is mostly administrative (passing out books, lesson plans, etc.). The objectives will also be covered. 1. Appreciate that the three primary objectives of CS1 are to develop your knowledge of: a) Problem Solving b) Computer Programming c) Computer Literacy 2. Understand the four levels of comprehension to lesson objectives. a)Appreciate: Casual knowledge b)Know: Essential recall of facts or information c)Understand: Amplification or extension of concepts and ideas. d)Be able to: Application of knowledge and understanding to new situations, also the ability to demonstrate a specific skill. Remember that problem solving and programming skills are oriented towards the "understand" and "be able to" levels. Literacy is oriented towards the "appreciate" and "know" levels. 3. Understand why we are studying computers and computer programming. Daily Lab #1: Introduction to the Terminal, Mail, and Games. See LAB1 Handout. 22 TITLE: LESSON 2 Introduction to the , the operating system, and the editor. 1. Know the three capabilities that make a computer useful. 2. Appreciate the history of "computers." 3. Know the four essential parts of computer hardware and the function of each. 4. Know the definition of "software." 5. Know the purpose of a computer program. 6. Understand the three basic elements of Data Processing. 7. Know the purpose of an operating system. [ 8. Be able to use the for file management. 9. Know the purpose of an editor. 10. Be able to use the editor to create and change a textfile. r. Daily Lab #2: Use of the Editor. See LAB2 handout. 23 LESSON 3 TITLE: Introduction to Ada SPECIFIC OBJECTIVES: 1. Appreciate the history of Ada and know why it was developed. 2. Know the purpose of the Ada compiler. 3. Know the difference between compiling, linking, and running a program. 4. Know the definition of a syntax error, an execution error, and a logic error. 5. Be able to use Appendix 1, "Daily Labs" to copy each Daily Lab into your directory. Daily Lab #3: LAB3.STU 24 LESSON 4 TITLE: Introduction to an Ada Program. SPECIFIC OBJECTIVES: 1. Appreciate the concept of top-down design with step-wise refinement. 2. Know the parts of an Ada program. 3. Know what reserved words, predefined words, and identifiers are. 4. Know the rules for forming identifier names and be able to r form valid identifier names. 5. Know the purpose of "comments" in Ada and how to put them in Ada code. 6. Know the two parts of a subprogram and know when each is { needed. --specification and body-- 7. Know where to "define" (or "declare") a subprogram. 8. Know what it means to "invoke" a subprogram. 9. Appreciate the purpose of an Ada Package. 10. Know how to make available the predefined Ada package TEXT IO in an Ada program using WITH and USE. 11. Know how to use the PUT LINE and NEW LINE statements made available by the package TEXT_IO. 12. Know what a syntax error is and understand its relationship with the Ada compiler. 13. Be able to use syntax diagrams to correct syntax errors. 14. Understand the simple punctuation rule in Ada. Daily Lab: LAB4.STU -- use the example cover sheet on the next page. 25 NAME : CLASS: SECTION: LESSON 4 -- EXAMPLE COVER SHEET TURN-IN INFORMATION DATE: ________________________________ __ ASSIGNMENT TITLE: __________________ _ COMMENTS CONCERNING THE LAB: 26 LESSON 5 TITLE: Writing and Using an Ada Package. SPECIFIC OBJECTIVES: 1. Understand the concept of a package. 2. Understand when a package should be used. 3. Know the two parts of a package. 4. Understand the difference between a package specification and a package body along with the purpose of each. 5. Be able to create and use an Ada package. 7. Be able to use NEW PAGE effectively. (from the package TEXT_IO) Daily Lab: LAB5.STU Remember to use NEW PAGE! 27 LESSON 6 TITLE: Declaring, Using, and Writing Variables SPECIFIC OBJECTIVES: 1. Know the two characteristics of a data type. 2. Know the three properties of any variable. 3. Know how to declare INTEGER and CHARACTER variables. 4. Be able to write simple assignment statements. 5. Know how to write values of type INTEGER in Ada-- eg., 1000 or 1 ooo instead of 1,000. 6. Know the values that can be assigned to a simple variable of type CHARACTER. 7. Be able to use the INTEGER arithmetic operators and be aware of their order of precedence. 8. Be able to use parentheses in arithmetic expressions to insure the operations are carried out in the desired order and be able to evaluate arithmetic expressions using operators, variables, and parentheses. 9. Understand what it means to "instantiate" a new package. 10. Be able to instantiate a new INTEGER IO package for the predefined type INTEGER and be able to output INTEGERs using this package. 11. Be able to output CHARACTERs using PUT statements available in the package TEXT_IO. 12. Be able to output messages and values of variables on a single line. 13. Understand the concept of a "storage location" and how it relates to the concept of a variable. Daily Lab: LAB6.STU 28 LESSON 7 TITLE: Subprograms with IN parameters SPECIFIC OBJECTIVES: 1. Be able to pass values from the invoking subprogram to a subprogram using IN parameters. 2. Be able to draw IPO diagrams of subprograms receiving values. 3. Know the difference between a "Formal Parameter List" and an "Actual Parameter List" and where each occurs. 4. Know the three ways of associating formal and actual parameters and which of the three is normally undesirable for readability. 5. When using positional association, know the three important properties which must be remembered (Number, Order, and Type of parameters must agree between the formal and actual parameter lists) . 6. When using named association, know that the number and type of parameters must agree between the formal and actual parameter lists. 7. Appriciate that using default values as parameter values changes the use of positional and named association. 8. Know the important rule that will always be observed concerning the use of variables in a subprogram. --only variables which are declared locally or are in the formal parameter list will be used in the· subprogram. 9. Know that an IN parameter may not have its value change in a subprogram. Daily Lab: LAB7.STU 29 LESSON 8 TITLE: GET and Subprograms with IN OUT and OUT parameters SPECIFIC OBJECTIVES: 1. Understand the purpose of main program variables (global variables), and be able to declare and use them correctly. 2. Be able to declare and use IN and IN OUT parameters to pass values between subprograms. 3. Be able to draw IPO diagrams of subprograms receiving and passing back values. 4. Be able to use GET effectively in conjunction with prompts and echochecks to input INTEGERs and CHARACTERs into a subprogram. 5. Know that an OUT parameter may not be used in a subprogram except to assign a value to it. 6. Know that an IN OUT parameter may be used in anyway in a subprogram. 7. Be able to draw and use "structure charts." Daily Lab: LAB8.STU 30 LESSON 9 TITLE: Selection and Boolean operators SPECIFIC OBJECTIVES: 1. Know the six relational operators available in Ada and how to use them. 2. Understand what Boolean expressions are and how to evaluate them. 3. Understand how to use the IF statement. 4. Understand how to use the IF-THEN-ELSE statement. 5. Understand how to use the IF-THEN-ELSIF statement. 6. Know how to use the logical operators AND, OR, XOR and NOT. 7. Be able to use and evaluate compound Boolean expressions. 8. Understand the advantage of using IF-THEN-ELSIF instead numerous IF-THENs. Daily Lab: LAB9.STU 31 LESSON 10 TITLE: CASE Statement SPECIFIC OBJECTIVES: 1. Be able to use the CASE statement effectively. 2. Know when to use a CASE statement in place of an IF-THENELSIF statement and when not to. 3. Know that the expression in the CASE statement must evaluate to a discrete value. 4. Know that ALL possible values the expression may take on must be taken care of in the body of the CASE statement. 5. Know how to use the WHEN OTHERS clause. in a CASE statement. Daily Lab: LAB10.STU 32 LESSON 11 TITLE: EXAM #1 SPECIFIC OBJECTIVES: 65% Ada, the editor, and operating system commands 35% literacy 33 LESSON 12 TITLE: Prolem Solving Formalized SPECIFIC OBJECTIVES: 1. Know the major steps in the "Problem Solving Methodology" as given in the handout. 2. Understand the concept of "deskchecking" and be able to deskcheck an Ada program. 3. Appreciate the need for program documentation and be able to document a program in accordance with Appendix 3. Daily Lab: Finish up any previous daily· labs that are incomplete. 34 LESSON 13 TITLE: FLOAT and BOOLEAN variables SPECIFIC OBJECTIVES: 1. Be able to declare and use FLOAT and BOOLEAN variables correctly. 2. Know how to convert the value in a variable of type INTEGER into a value of type FLOAT and be able to use this in an assignment statement. 3. Know that the arithmetic operators REM and MOD are not applicable to variables of type FLOAT. 4. Be able to instantiate a new FLOAT IO package predefined type FLOAT. for the 5. Be able to input and output FLOATs in a readable form using fieldwidths. Daily Lab: LAB13.STU 35 LESSON 14 TITLE: WHILE Loops and the "Trailer" Technique SPECIFIC OBJECTIVES: 1. Understand the concept of iteration. 2. Understand the "basic" loop and how it may result in an infinite loop. 3. Appreciate the EXIT statement and the reasons why it will not be used in our course. --readability suffers, etc. 4. Be able to use the WHILE loop effectively and understand in which situation it is useful. 5. Understand the difference between an IF-THEN statement and a WHILE statement, and when each should be used. 6. Be able to use the "Trailer" Technique effectively. 7. Know the meaning of the acronym 'ITEM'. 8. Be able to apply ITEM to control the WHILE loop. 9. Know the common error which results in an "infinite loop" when using the WHILE loop. Daily Lab: LAB14.STU 36 LESSON 15 TITLE: Computer Exercise #1 HOMEWORK: Prior to class review the handout on "Problem Methodology" and read the Computer Exercise #1 handout. SPECIFIC OBJECTIVES: Solving 1. Be able to use the problem solving methodology to program a solution to Computer Exercise #1. 2. Be able to document a program IAW Appendix 3. Daily Lab: The lab time will now be used to accomplish Computer Exercise #1. You will probably need to also use the lab outside of your normal lab time. 37 LESSON 16 TITLE: FOR Loops and the "Header" Technique SPECIFIC OBJECTIVES: 1. Be able to use the FOR Loop (counting loop) effectively and understand in which situations it is useful. 2. Be able to decide in a given situation if the FOR or WHILE loop is appropriate. 3. Know how ITEM applies to a FOR loop. 4. Be able to use the "Header" Technique effectively. 5. Know the three types of control structures in structured programming and which Ada statements implement each. 6. Appreciate the (four) results of "structured programming." 7. Know the definition of Top-Down design. 8. Appreciate the concepts of "coupling" and "cohesion." 9. Appreciate the concept of "pseudocode" and the advantages of its use. 38 LESSON 17 TITLE: Literacy SPECIFIC OBJECTIVES: 1. More literacy (this gives time for answering questions on the computer exercise). 39 LESSON 18 TITLE: Algorithms SPECIFIC OBJECTIVES: 1. Know the definition of an "algorithm." 2. Know the four characteristics of any good algorithm and understand why they are important. 3. Be able to find the average of a group of numbers. 4. Be able to find the maximum andjor minimum value of a group of numbers. 40 LESSON 19 TITLE: Functions SPECIFIC OBJECTIVE: 1 . Understand the concept of a predefined function and be able to use the predefined function 'ABS'. 2. Know where a function must be invoked. 3 . Know when it is appropriate to use user-defined functions. 4. Be able to write and invoke user-defined functions. 5. Know the three important items to remember when writing [ a user-defined function. 6. Know the two common errors made when writing a J function. 7. Appreciate the concept of recursion and what may happen r when recursion is inadvertently used. L. 8. Be able to draw IPO diagrams for user-defined functions. Daily Lab: LAB19.STU 41 LESSON 20 TITLE: EXAM #2 TOPICS COVERED: 65% Ada and Problem Solving 35% literacy 42 LESSON 21 TITLE: Constants, Numbers, Types, Subranges, Subtypes, and One-Dimensional Arrays SPECIFIC OBJECTIVES: 1. Be able to declare constants and numbers and also be able to use them effectively. 2. Be able to declare subranges of INTEGERs and FLOATs. 3. Be able to use the predefined subtypes NATURAL and POSITIVE. 4. Know the difference between a constant/number and a subrange and know how to use them together in an Ada program. 5. Know the two situations where an array is useful. 6. Be able to use an array effectively. 7. Understand why arrays and iteration are useful together. 8. Know why it is advantageous to read values into an array in a separate module. 9. Be able to find the average, maximum, and minimum values of a group of numbers using arrays. 10. Understand how the execution error " ·subscript out of range" is caused. 43 LESSON 22 TITLE: Review of Functions, Types, Subranges, Subtypes, Constants, and One-Dimensional Arrays SPECIFIC OBJECTIVES: 1. Be able to write and invoke user-defined functions correctly. 2. Be able to declare an array type and an array variable of that type. 3. Be able to use an array effectively. 4. Be able to find the average, maximum, and minimum values of a group of numbers using arrays. 5. Be able to declare constants and use them effectively. 6. Be able to declare subranges and use them effectively. 44 LESSON 23 TITLE: Searching SPECIFIC OBJECTIVES: 1. Know the definition of a "sequential search." 2. Be able to recognize situations where a search is r required. 3. Understand how logic errors are caused and know how to go about correcting them. 4. for. Know what "parallel arrays" are and what they are used 45 LESSON 24 TITLE: Sorting SPECIFIC OBJECTIVES: 1. Know the role "searching" accomplishes in a "sort." 2. Be able to find the location (index) of the smallest/largest item in an array. 3. Be able to switch information between two locations in an array. 4. Understand the simple difference in logic to effect ascending and descending sorts. 5. Know how to use "parallel arrays." 46 LESSON 25 TITLE: COMPUTER EXERCISE #2 SPECIFIC OBJECTIVES: Read Computer Exercise #2. Be ready to ask any questions when your instructor reviews the exercise. 47 LESSON 26 TITLE: Review: Sorting and Searching SPECIFIC OBJECTIVES: 1. 2. 3. Be able to accomplish a "sort" using Ada. Be able to accomplish a "search" using Ada. Be able to sort parallel arrays. 48 LESSON 27 TITLE: Two-Dimensional Arrays and Variables of type STRING SPECIFIC OBJECTIVES: 1. Know how to declare, access, and use two-dimensional arrays effectively. 2. Be able to read data into a two-dimensional array. 3. Be able to write out the contents of two-dimensional arrays. 4. Understand that searching or sorting a two-dimensional array means searching or sorting based on a particular column. 5. Be able to search and sort a two-dimensional array. 6. Be able to use nested iteration effectively. 7. Be able to use variables of type STRING. 49 LESSON 28 TITLE: Reading from External Data Files SPECIFIC OBJECTIVES: 1. Understand what an external data file is and what it is used for. 2. Be able to write Ada subprograms that read information from an external data file. 3. Understand how END OF FILE can be used in the trailer technique, and be able to use it efffectively to read information from a file. 4. Understand that we are reading information from a file sequentially. 50 LESSON 29 TITLE: Records and Writing to External Files SPECIFIC OBJECTIVES: 1. Understand the concept of a record. 2. Understand the difference between an array of a particular predefined type (INTEGER, FLOAT, BOOLEAN, or CHARACTER) and an array of records and when each should be used. 3. Be able to sort and search an array of records. 4. Be able to write output to an external file other than STANDARD OUTPUT. 51 LESSON 30 TITLE: Recursion and Sets SPECIFIC OBJECTIVES: 1. Understand what recursion is and what it is used for. 2. Understand what sets are and how they are used. Note: Review LAB19.STU for recursion. 52 LESSON 31 TITLE: Ada Review SPECIFIC OBJECTIVES: 1. Review the concepts of the Ada language covered thus far. 2. Appreciate that only part of the Ada language has been covered and that Ada is a full-bodied language able to accomplish many tasks. 53 LESSON 32 TITLE: EXAM #3 SPECIFIC OBJECTIVES: 65% Ada and Problem Solving 35% literacy 54 LESSON 33 TITLE: Computer Exercise #3 SPECIFIC OBJECTIVES: Read Computer Exercise #3. Be ready to ask any questions when your instructor reviews the exercise. 55 Student Lessons Appendix 1 DAILY LABS Daily labs are used to immediately reinforce material that has just been covered in class. Many of the early labs will consist of completing a program that is partially done. When there is a daily lab to be accomplished, use the step-bystep process described below to print out the lab. Accomplish this before coming to classjlab so you have a chance to prepare and thus, make maximum use of lab time. This Appendix is implementation dependant. Below is an example of how it would be done on a personal computer using ·Janus Ada. 1. Put DOS in Drive A and boot the PC. 2. Place the master diskette in Drive A, and your diskette in Drive B. 3. Copy LESSON.LAB B:LESSON.ADA where n is the lesson number you are on. This command copies the daily labb from a Master diskette to your diskette under the name LESSON.ADA. 4. Check your diskette's directory to insure there is a file called LESSON.ADA. DIR B: 5. Print the file on the line printer. PRINT B:LESSON.ADA 6. You are finished. Now, follow the directions on your listing to accomplish the lab. 56 student Lessons Appendix 2 PROBLEM SOLVING METHODOLOGY When given a large problem, one normally breaks the problem down into smaller subproblems. Each subproblem is tackled in turn and solved. Once all the subproblems are solved in the proper order, the overall larger problem has been solved. This is the way we are going to approach computer problem solving. The following will give you some steps to follow to help convert your problem J into a computer solution using Ada. REMEMBER, however, that problem solving takes practice to become good at it. STEP 1: [ 1. PROBLEM STATEMENT: write a statement of the complete problem in your own words. 2. MAIN TASKS: from the problem statement, write out the main tasks which must be completed to solve the problem. These are the "subproblems" which make up the overall problem to be solved. since tasks show action, you should be looking to the VERBS in your problem statement to give you an indication of what tasks are to be performed. 3. STRUCTURE CHART: Draw a structure chart. This will show you the overall structure of your program. Choose meaningful names for each subprogram. 4. REFINEMENT OF EACH TASK: since we identified the 11 subproblems11 which make up the overall problem, we must start to solve each one of these in turn. Thus, for each of the Main Tasks identified in step 2, accomplish the following (normally on a separate page for each subproblem): a. SUBPROBLEM STATEMENT: write a problem statement of the subproblem. Once again, note the VERBS in your subproblem statement. Also, note the NOUNS, since they will help you identify the parameters for this subproblem. b. PARAMETER IDENTIFICATION: First, list the items that the subproblem needs from the outside world to perform its overall task. These will be IN parameters. Next, list the items that the subproblem is supposed to provide to the outside world. These will be OUT parameters. If any item appears on both the IN list and OUT list, this item becomes an IN/OUT parameter. 57 c. IPO DIAGRAM: draw an IPO diagram using the list above. This will help you visualize the flow of data items. d. ADA PROCEDURE SPECIFICATION and STUBBED BODY: using the IPO diagram, write the Ada procedure specification and a stubbed body. A stubbed body is when the procedure body contains a single PUT LINE statement that shows this procedure was invoked. We will put off actually solving the subproblem until after we are sure all the subproblems fit together in the main problem (main procedure) with no errors. 5. MAIN ADA PROCEDURE: once all the subproblem procedure specifications are complete, invoke these procedures in the order needed to solve the overall problem. Insure that each procedure returns the items any other (later) procedure needs. If new OUT (or IN/OUT) parameters are needed, note them on the appropriate IPO diagram and make the same changes in that subprogram specification and the subprogram invocation. Then, from each subproblem specification, identify the main procedure variables (and their types) which need to be declared. Using the Ada compiler as necessary, remove all the syntax errors. Once the syntax errors are removed, you have solved part of the overall computer problem. You may now start solving each subproblem in turn. 58 STEP II: For each subproblem identified in step 14, accomplish the following (some of the steps may already have been done in step I) : 1. SUBPROBLEM STATEMENT: insure that what you wrote in Step I for the subproblem statement is really what this subproblem is supposed to accomplish. Once again, notice the VERBS. These will help you identify the specific tasks this subproblem is to accomplish. 2. IPO DIAGRAM: review the IPO diagram for the items needed by this subproblem and the items to be returned by this subproblem. 3. SUBPROBLEM TASKS: enumerate the specific tasks this subproblem is to accomplish. Insure that you have all the information (items) needed to accomplish the task and that all the items to be returned by this subproblem are available at the end of the subproblem. If you realize you need more items, note these new parameters on the IPO diagram. 4. ADA STATEMENTS WRITTEN: write the Ada statements needed to accomplish the tasks. If any task cannot be "translated" into a single Ada statement, this task must be broken down into subtasks. If it is a very large task with numerous subtasks, you should accomplish Step II for it (ie., it will become another Ada subprogram) . 5. ADA MAIN PROCEDURE CHECKED: Insure that the actual and formal parameter lists still agree (in case any changes had to be made in the subprogram specifications). Additionally, insure that any required packages needed by the subprograms are instantiated. 59 The following is a complete example (using LAB_lO) showing the use of steps I and II. STEP I: 1. PROBLEM STATEMENT: Write a program which reads in a date, computes the day of the week for this date, and then prints out the information. 2. MAIN TASKS: a. Read in the date. b. Compuute the day of the week using the date from a. c. Print out the date and day of the week. 3. STRUCTURE CHART: MAIN READ IN DATE COMPUTE DAY OF WEEK PRINT INFORMATION 4. REFINEMENT OF EACH TASK: See the following pages for each subprogram. 60 4. REFINEMENT OF TASK READ IN DATE: a. SUBPROBLEM STATEMENT: Read in the date from the keyboard in the form of day, month, and year. Day, month, and year will be integers. b. PARAMETER IDENTIFICATION: TThis procedure is supposed to read in DAY, MONTH, and YEAR. It needs nothing from the invoking procedure. Thus, IN parameters are DAY, MONTH, and YEAR (all integers). c. IPO DIAGRAM: READ IN DATE DAY MONTH YEAR d. ADA PROCEDURE SPECIFICATION and STUBBED BODY: procedure READ_IN_DATE ( DAY, MONTH, YEAR : out integer ) is begin -- READ_IN_DATE put_line ("Procedure READ IN DATE has been invoked."); end READ_IN_DATE; 61 4. REFINEMENT OF TASK COMPUTE DAY OF WEEK: a. SUBPROBLEM STATEMENT: Given the DAY, MONTH, and YEAR, calculate the day of the week. b. PARAMETER IDENTIFICATION: IN parameters -- Need DAY, MONTH, and YEAR (integers) from the invoking subprogram. OUT parameters-- DAY_OF_THE_WEEK (integer). c. IPO DIAGRAM: DAY MONTH YEAR DAY OF WEEK COMPUTE DAY OF WEEK d. ADA PROCEDURE SPECIFICATION and STUBBED BODY: procedure COMPUTE_DAY_OF_WEEK (DAY, MONTH, YEAR : in integer; DAY OF WEEK :out integer ) is begin -- COMPUTE_DAY_OF_WEEK PUT LINE (Procedure COMPUTE DAY OF WEEK has been invoked"); end COMPUTE_DAY_OF_WEEK; 62 4. REFINEMENT OF TASK PRINT INFORMATION: a. SUBPROBLEM STATEMENT: date in a readable format. Print out the day of the week and b. PARAMETER IDENTIFICATION: IN Parameters -- need DAY OF WEEK, DAY, MONTH, and YEAR from the invoking subprogram. Nothing will be returned to the invoking subprogram. c. d. IPO DIAGRAM: DAY MONTH YEAR DAY OF WEEK PRINT INFORMATION ADA PROCEDURE SPECIFICATION and STUBBED BODY: procedure PRINT_INFORMATION ( DAY, MONTH, YEAR, DAY OF WEEK : in integer begin -- PRINT_INFORMATION is PUT LINE ("Procedure PRINT INFORMATION has been invoked."); end PRINT_INFORMATION; 63 Once all the subproblems have been "stubbed" out, the main Ada procedure may now be written. Additionally, the variables needed in the main procedured may be declared. 5. MAIN ADA PROCEDURE: with TEXT_IO; procedure MAIN is use TEXT_IO; -- the main procedure variables declared here DAY, MONTH, YEAR, DAY OF WEEK integer; begin -- MAIN READ_IN_DATE ( DAY, MONTH, YEAR ); COMPUTE_DAY_OF_WEEK (DAY, MONTH, YEAR; DAY OF WEEK); PRINT INFORMATION ( DAY, MONTH, YEAR, DAY OF WEEK ); end MAIN; 64 STEP II is accomplished for each of the subproblems identified in Step 14. REFINEMENT OF TASK READ IN DATE: 1. SUBPROBLEM STATEMENT: Read in the date from the keyboard in the form of DAY, MONTH, and YEAR. DAY, MONTH, and YEAR will be integers. 2. IPO DIAGRAM: DAY MONTH YEAR READ IN DATE 3. SUBPROBLEM: a. b. c. Prompt for and read in DAY. Prompt for and read in MONTH. Prompt for and read in YEAR. 4. ADA STATEMENTS WRITTEN: procedure READ IN DATE (DAY,MONTH,YEAR out integer) is begin -- READ_IN_DATE PUT LINE ("Please input the day of the month: II ); GET (DAY); PUT LINE ("Please input the month (1-12): II ) i GET (MONTH); PUT LINE ("Please input the year (19XX) : II ) i GET (YEAR); end READ_IN_DATE; 5. ADA MAIN PROCEDURE CHECKED: The formal and actual parameter lists agree. Need to instantiate the package for INTEGER I/0: package INT_IO is new INTEGER IO ( INTEGER ); use INT_IO; 65 REFINEMENT OF TASK COMPUTE DAY OF WEEK: 1. SUBPROBLEM STATEMENT: Given the DAY, MONTH, and YEAR, calculate the day of the week. 2. IPO DIAGRAM: DAY MONTH YEAR COMPUTE DAY OF WEEK DAY OF WEEK 3. SUBPROBLEM TASKS: a . . Get MONTH, DAY, and YEAR from the invoking procedure. b. Since we may need to change the values in MONTH and YEAR, assign the value in MONTH to NEW MONTH and YEAR to NEW YEAR. c. d. e. f. g. h. i. j . k. 1. Subtract 2 from NEW MONTH. If NEW MONTH is less than or equal to 0 -- add 12 to NEW MONTH -- subtract 1 from NEW YEAR Compute CENTURY as the-integer part of NEW YEAR/100. Compute NEW YEAR as the the remainder of NEW YEAR/100. Compute A as the integer part of . - (13 * NEW MONTH - 1)/5. Compute B as the integer part of NEW_YEAR/4. Compute C as the integer part of CENTURY/4. Compute D as A + B + C + DAY + NEW YEAR - (2*CENTURY). Compute DAY OF WEEK as the remainder of D/7. Pass DAY OF-WEEK back to the invoking procedure. 66 4. ADA STATEMENTS WRITTEN: procedure COMPUTE_DAY_OF_WEEK (DAY,MONTH,YEAR DAY OF WEEK --local variables NEW_MONTH, NEW_YEAR, CENTURY, A, B, C, D : integer; begin -- COMPUTE_DAY_OF_WEEK NEW_MONTH :=MONTH - 2; NEW YEAR := YEAR; if NEW MONTH when 2 => when 3 => when 4 => when 5 => when 6 => when 7 => when 8 => when 9 => when 10 => when 11 => when 12 => PUT PUT PUT PUT PUT PUT PUT PUT PUT PUT PUT PUT when others => end case; PUT (YEAR, 4); PUT (" is a "); case DAY OF WEEK is (' January " ); ( February " ); ( March " ); ( April " ); ( May " ); ( June " ); ( July " ); ( August " ); ( September " ); " October " ); (" November " ); (" December " ); PUT LINE ("Error PUT ("Month = " ); PUT (MONTH, 4); when 0 => PUT ("Sunday."); when 1 =>PUT ("Monday."); when 2 => PUT ("Tuesday. "); when 3 => PUT ("Wednesday. "); when 4 => PUT ("Thursday."); when 5 =>PUT ("Friday."); when 6 => PUT ("Saturday"); in i' n integer) is month --"); when others => PUT LINE ("Error in DAY OF WEEK --"); PUT ("DAY_OF_WEEK = "); end case; NEW_LINE (2); end PRINT_INFORMATION; PUT (DAY_OF_WEEK, 4); 5. ADA MAIN PROCEDURE CHECKED: The actual and formal parameters agree. The package for integer I/O has already been instantiated. 69 student Lessons Appendix 3 DOCUMENTATION STANDARDS This document does not attempt to cover all programming conventions or situations. It should be used as a set of minimum standards when developing your programs. The "style" or format of how your program is laid out and the comments that you include in the program are as important as the code itself. Any point of style not covered in this standard is left open for you to implement in a consistent and readable fashion. The end result should be for you to write clear, concise, well-structured, readable programs. 1. General Requirements: a. Each subprogram will do only one task and will be "named" using a verb which shows the action the subprogram will accomplish. b. All subprograms will contain a "Title Section" blocked off at the beginning. It will outline the purpose of the subprogram. Example of a Title Section for an entire program: Program Computer Exercise #2 Written by This program . Example of a Title Section for a specific subprogram: Procedure -- this procedure . Tasks: 1. 2 • • ••• n. . . 70 2. Declarations: a. Do not use any variables (except filenames) in a ·procedure or function that do not occur either in the procedure/function formal parameter list or in the local variable declaration section of the procedurejfunction. b. Any variables that are not self-documenting must have comments explaining exactly what they are. For example, TOTAL_PAY_PER_MONTH is self-documenting, while PAY is not. Therefore, PAY would need a comment explaining which pay it was. You should strive to have your variables be self-documenting. c. Each formal parameter will have either IN, IN OUT, or OUT associated with it. The parameters should be · written and grouped in such a way that they are readable. The parameters, colons, modes, and type names should be aligned when possible. d. Associated declarations should be grouped together with at least one blank line appearing between groups. In other words, all new type declarations should be in one group, variables in another, etc. Example: MAX - NUMBER- OF - TESTS MAX NUMBER STUDENTS type GPA LIST is array type SSN LIST is array GPA GPA_LIST; SSN SSN_LIST; constant integer := 50; constant integer := 5000; l . MAX - NUMBER- STUDENTS l . MAX NUMBER STUDENTS of float; of integer; e. The BEGIN statement of each procedure/function will include a comment giving the name of the procedurejfunction. The name of the subprogram will be used with the END statement. begin -- READ IN DATA end READ_IN_DATA; 71 3. Indentation and Spacing: a. Standard indentation is 2 spaces. skip to the next line and indent 2 spaces. Examples: LOOPS while loop; end loop; for loop; end loop; IF STATEMENTS if then; else; end if; if then; elsif then; end if; CASE STATEMENTS case when => when => when others => end case; is; 72 For each "level", b. Spacing of arithmetic expressions -- at least one space r before and after each operator: MONTHLY PAY := HOURS WORKED * RATE OF PAY + [ ( HOURS_WORKED - 40.0 ) * 0.5; c. Use parentheses and alignment in boolean expressions to increase readability. if ( NEW_WORKER and HOURS_WORKED < 40.0 ) or ( EXPERIENCED WORKER and HOURS WORKED >= 40.0 ) then; end if; 73 II.II Instructor Lesson Plans 74 INSTRUCTOR LESSON PLANS LESSON 1 TITLE: Introduction to CS1 SPECIFIC OBJECTIVES: Note: This lesson is mostly administrative (passing out books, lesson plans, etc.). The objectives below will also be covered. 1. Appreciate that the three primary objectives of CS1 are to develop your knowledge of: a. Problem Solving b. Computer Programming c. Computer Literacy 2. Understand the four levels of comprehension to lesson objectives. a. Appreciate: Casual Knowledge. b. Know: Essential recall of facts or information. c. Understand: Amplification or extension of concepts and ideas. d. Be able to: Application of knowledge and understanding to new situations, also the ability to demonstrate a specific skill. Remember that problem solving and programming skills are oriented towards the "understand" and "be able to" levels. Literacy is oriented towards the "appreciate" and "know" levels. 3. Understand why we are studying computers and computer programming. ===> c;w, chap 1 Daily Lab #1: There will be a separate handout for this lab since it is implementation dependent. It will cover (step by step) how to log on the computer, how to get help (computer generated), how to send mail to the instructor, how to log off, how to interrupt a "process", how to stop and start scrolling, etc. They will get used to the terminal by completing this lab and then playing "Games" (such as Adventure, etc.). 75 LESSON 2 TITLE: Introduction to the , the operating system and the editor 1. Know the three capabilities that make a computer useful. ===> Speed, Accuracy, and Memory 2. Appreciate the history of "computers." ===> c;w, Chap 3 3. Know the four essential parts of computer hardware and the function of each. ===> c;w, pp. 19-27 -- CPU, Secondary Storage, Input Devices, and Output Devices. 4. Know the definition of "software." ===> c;w, p.30, "The planned, step-by-step instructions required to turn data into information." Give some examples: the editor, mail utility, etc. 5. Know the purpose of a computer program. ===> c;w, p.18, "A series of step-by-step instructions that directs the computer to do the tasks you want it to do and produce the result you want." 6. Understand the three basic elements of Data Processing. ===>Input, Processing, Ouput (from class notes). 7. Know the purpose of an operating system. ===> C/W, p. 252, "A set of programs that allows the computer [ system to manage its own resources." + (class notes). 8. Be able to use the for file management. ===> Cover by example -- the specific commands to be covered are implementation dependent. 9. Know the purpose of an editor. ===> Allows you to create and correct programs. (class notes) 10. Be able to use the editor to create and change a textfile. ===> Cover the lab they will accomplish and the specific commands they will be introduced to. 76 Daily Lab #2: There will be a separate handout for this lab since it is machine and editor dependent. Using the editor, they will type in a given file, make specific changes to it, and then print it out. The changes will demonstrate the capabilities of the editor in a step-by-step manner. 77 LESSON 3 TITLE: Introduction to Ada SPECIFIC OBJECTIVES: 1. Appreciate the history of Ada and know why it was developed. ===> From class notes or the book. 2. Know the purpose of the Ada compiler. ===> Translates a high-level language (Ada) program into its own machine language. Use the diagram in C/W on page 261 to tie this and objective 3 together. 3. Know the difference between compiling, linking, and running a program. ===> See above. 4. Know the definition of a syntax error, an execution error, and a logic error. ===> Syntax error -- when the program contains words, grammar, or [ punctuation that the compiler doesn't understand. Execution error -- when your program doesn't have any syntax errors and then you ask the computer to do something it cannot do. Logic error -- when your program has no syntax or execution errors, yet it doesn't accomplish the task you wanted it to. ===> Give examples -- a good, real life example is when someone asks you directions to London. Syntax error -- "You gibbed thry 50 miles, then fraggle on an dingle." Execution error "You travel by car to Houston Intercontinental. You then rent a Cessna 150 and fly to London." (p.s., this is impossible in a Cessna 150) Logic Error "You travel by car to Houston Intercontinental. You then get on a plane traveling due south for 500 miles. When the plane lands you will be in London." 5. Be able to use Appendix 1, "Daily Labs" to copy each daily lab into your directory. ===> Explain that the daily labs are used to reinforce the concepts learned that day in class. They should get a printout of the daily lab the day before class. This way they can prepare themselves to use the lab period effectively. Cover the steps in Appendix 1. ===> Daily Lab #3 78 LESSON 4 TITLE: Introduction to an Ada Program SPECIFIC OBJECTIVES: 1. Appreciate the concept of top-down design with step-wise refinement. ===> The process of breaking a large problem into its logical subproblems. These subproblems are then solved one at a time. Once the subproblems are solved and "fitted" together in the proper order, the overall large problem is solved. Give an example (ie., baking a cake, sending a man to the moon, etc.). 2. Know the parts of an Ada program. ===> Use the program they ran of LAB3 to illustrate the overall structure. ===> Basically it is: with ; is ; begin; end; 3. Know what reserved words and identifiers are. ===> Reserved words are used to structure an Ada program. They have special meaning to the Ada compiler and CANNOT be changed in meaning. ===> Identifiers are meaningful names given to subprograms and variables. ===> Point out the reserved words and identifiers in LAB3. 4. Know the rules for forming identifier names and be able to form valid identifier names. ===> Must start with a letter, letters or digits. Underscores used to increase readability. significant but that case is not. followed by any combination of (no more than 1 in a row) may be Explain that underscores are ie., read_scores /= readscores = READSCORES 5. Know the purpose of "comments" in Ada and how to put them in Ada code. ===> To increase program readability by HUMANS. Denoted with the double hyphen -- always extends through the end of the line and no further. 79 6. Know the two parts of a subprogram and know when each is needed. ===> Specification and body -- show that the specification may be separate from the body for readability (if have many subprograms), however it need not be. Give an example each way. In this course, the programs will normally be such that they will not need to separate the specification and body. 7. Know where to "define" (or "declare") a subprogram. ===> Show where using LAB3 to illustrate. 8. Know what it means to "invoke" a subprogram. ===> Actually causes the code (task) in the subprogram to be executed (accomplished). 9. Appreciate the purpose of an Ada Package. ===> Allows the programmer to group a set of logically related declarations (initially for the students - subprograms) together. This package may be separately compiled and used in other programs. Introduce the concept of reusability (toolbox). Tie this into objective #10. This is just an introduction. Packages will be covered in more depth next lesson. 10. Know how to make available the predefined Ada package TEXT_IO in an Ada program using WITH and USE. ===> Insure they have the concept of what is happening with WITH and also USE. Show where each occurs. 11. Know how to use the PUT LINE and NEW LINE statements made available by the package TEXT !o. ===> Insure that they use STANDARD OUTPUT by using PUTs, NEW_LINEs, etc. This makes it much easier when we get to reading and writing of external files. ===> Emphasize that the string uses double quotes and that at the end of the PUT_LINE the "carriage is returned." Also show how more than one line may be skipped with a single statement - NEW_LINE (standard_output, ). 12. Know what a syntax error is and understand its relationship with the Ada compiler. ===> They have already been introduced to the definition of a syntax error. Show some specific examples using Ada. 13. Be able to use syntax diagrams to correct syntax errors. ===> Show by example. Show some wrong syntax and how to use the 80 diagrams to correct them. Start emphasizing use of the diagrams now and this will help take part of your extra instruction load off later. 14. Understand the simple punctuation rule in Ada. ===> The semicolon is used to TERMINATE statements (not separate statements as in Pascal). Daily Lab #4: They will initially compile LAB4.STU. There will be syntax errors. They are to correct the syntax errors to get a valid Ada program. They will then change the program so that it will output a cover sheet as shown in their lesson plans. 81 LESSON 5 TITLE: Writing and Using an Ada Package SPECIFIC OBJECTIVES: 1. Understand the concept of a package. ===> You have introduced it last lesson. again and show when it should be used. Go over the concept 2. Understand when a package should be used. 3. Know the two parts of a package. ===> Package specification and package body. 4. Understand the difference between a package specification and a package body along with the purpose of each. ===> The package specification is the "window" into the package. Shows the user of the package what is available for their use and how to invoke any of the subprograms. This is where we use the subprogram specification. ===> The package body actually implements the task(s) the subprograms in the package are supposed to acccomplish. It has the bodies of all of the subprograms. (You may also mention that declarations and subprograms used only in the package are also declared here. ) 5. Be able to create and use an Ada package. ===> Go over the structure of a package. Go through a detailed example. 6. Understand the concept of separate compilation and that the "order" of compilation matters. ===> Show with your example the order of compilation and how the package would be used. 7. Be able to use NEW PAGE (from the package TEXT_IO) effectively. ===> Skips to the top of the next page of output. Proper use is: NEW_PAGE (standard_output); until external files are introduced . Daily Lab: LABS. STU -- They will put the procedure they developed to output their name, address, section, etc. into an Ada package. They will then use this pacckage in another program to output their information. They will use this package for every turn-in (shows reusability). Insist that they use NEW PAGE to have the cover sheet on its own page. 82 LESSON 6 TITLE: Declaring, Using, and Writing Variables SPECIFIC OBJECTIVES: 1. Know the two characteristics of a data type. ===> A data type has a set of legal values and a set of operations applicable to those values. Give examples. 2. Know the three properties of any variable. ===> Has a type (refers to #1), has a meaningful name (our desired property), and can only contain a single. value at a time. 3. Know how to declare INTEGER and CHARACTER variables. ===> Show in the program structure. Emphasize that you are just naming a "location" and telling the compiler what the legal values and operations are for this variable. We have NOT given the variable a value yet unless we explicitly assign a value to it. Give examples of INTEGER and CHARACTER values (tie in objective 4 and 5). 4. Be able to write simple assignment statements. ===> Emphasize that the exprssion on the right-hand side of the statement is completely evaluated first, yielding a single value. This value is THEN assigned to the variable on the left only if it is of the SAME type as the variable (error if not the same type) . Also show how an initial value (in the declaration statement) may be assigned to the variable. ===> Students have particular problems with the same variable on the left and right side of the statement. For example: TOTAL := 3; TOTAL :=TOTAL + 7; Set up boxes, tables, etc. (whatever your technique is) to keep track of the values that are each variable. Deskcheck a fairly complicated group of statements. Another example: A, B, c: character:=' '; begin example A:= 'Z'; B :='A'; C := A; end; What is in each variable at the end of the beginjend block? Show why meaningful names (as in this case) are important. 83 5. Know how to write values of type INTEGER in Ada -- eg., 1000 or 1 ooo instead of 1,000. 6. Know the values that can be assigned to a simple variable of type CHARACTER. ===> Emphasize that any character may be assigned, digits 'O '9', punctuation, and a blank. realize that a blank is a character. Remember difference between a single character and a string is denoted-- single and double quotes). INCLUDING the Insure they to show the (and how each 7. Be able to use the INTEGER arithmetic operators and be aware of their order of precedence. ===> Give numerous examples. MOD. Especially show the ;, REM, and 8. Be able to use parentheses in arithmetic · expressions to insure the operations are carried out in the desired order and be able to evaluate arithmetic expressions using operators, variables, and parentheses. ===> Show them that if they have any doubts as to what operation is going to be performed first, second, etc., use parentheses to insure the desired order is followed. 9. Understand what it means to "instantiate" a new package. ===> Keep this discussion at a simple level. Just show that (in this case) we are making certain operations available for specific types. 10. Be able to instantiate a new INTEGER IO · package for the f: predefined type INTEGER and be able to outpui:INTEGERs using this Lj package. ===> Show by example where the package is instantiated and the ~ use of PUTs. Insist that they use the fieldwidth to control exactly where the output will be on the line. This will make it easier when they get to output of FLOATs. 11. Be able to output CHARACTERs using PUT statements available in the package TEXT_IO. ===> Show by example. Remember to have them specify the file (ie., STANDARD OUTPUT). 12. Be able to output messages and values of variables on a single line. ===> Show by example. 84 13. Understand the concept of a "storage location" and how it relates to the concept of a variable. ===> C/W, p 74. Daily Lab: LAB6.STU 85 LESSON 7 TITLE: Subprograms with IN Parameters. SPECIFIC OBJECTIVES: 1. Be able to pass values from the invoking subprogram to a subprogram using IN parameters. ===> Show the new program structure. Don't bother right now with separating the subprogram specification and body. Insure you stress that "values" are passed through the parameter list and not variables, names, etc. In other words, the names of the formal and actual parameters need not match. 2. Be able to draw IPO diagrams of subprograms receiving values. ===> Introduce doing. IPO' s as a graphical depiction of what we are IN PARAMETERS v name of the subprogram 3. Know the difference between a "Formal Parameter List" and "Actual Parameter List" and where each occurs. ===> This lays the foundation for the "rules" for parameters we cover in the following objectives. A technique for teaching this is to say the formal parameter list creates "boxes" in the modules that can accept VALUES from outside the module. 4. Know the three ways of associating formal and actual parameters and which of the three is normally undesirable for readability. ===> a) b) c) ===> an positional - only order counts. named - order doesn't count since names are used. Especially good when passing a constant in. using default values - undesirable at this stage when they are learning to use subprograms and parameters. Also normally undesirable for readability. Used when the subprogram has parameters whose actual values do not change over most calls. example they are already familiar with is: 86 NEW LINE (FILE => standard output, SPACING => 2}; NEW LINE ( standard output, 2); NEW LINE ( standard=output); -- using default of 1 5. When using positional association, know the three important properties which must be remembered (Number, Order, and Type of parameters must agree between the formal and actual parameter lists.) ===> Stress this point since this is where much confusion lies with students. Use numerous examples showing this relationship and the concept that names of the formal parameters are not important (except that they should be meaningful names). 6. When using named association, know that the number and type of parameters must agree between the formal and actu'al parameter lists. ===> Once again show with numerous examples. Show that the only difference between positional and named association is that (with named) we are giving the compiler information about where the values of the actual parameters are to be put in the subprogram. Therefore, the order of the actual parameters does not have to be the same as the formal parameters (although it is normally not a good technique) . Used to increase the readability of subprogram calls (especially when passing constants into the subprogram). For example: MAKE CHANGE ( 105 ); vs. MAKE CHANGE ( ORIGINAL AMOUNT => 105 ); 7. Appreciate that using default values as parameter values changes the use of positional and named association. ===> Once the subprogram call uses a "default" value, then the remainder of the actual parameters must use named association. Give an example. 8. Know the important rule that will always be observed concerning the use of variables in a subprogram. ===> Only variables which are declared locally or are in the formal parameter list will be used in the subprogram. This is our rule to help enforce topdown design and stepwise refinement. Each subprogram stands alone. 9. Know that an IN parameter may not have its value change in a subprogram. ===> This objective may disappear depending on the Ada implementation. Some compilers are accepting this (depending on how the MILSTD was interpreted). In other words, you cannot use the formal IN parameter as a temporary variable. Daily Lab: LAB7.STU 87 LESSON 8 TITLE: GET and Subprogram with IN OUT and OUT parameters SPECIFIC OBJECTIVES: 1. Understand the purpose of main subprogram variables (global variables), and be able to declare and use them correctly. ===> First define "main subprogram" as the procedure which drives the program. It is the procedure which is the controller and which calls the other subprograms in the proper order. ===> We will use main program variables to temporarily hold values in the main subprogram. They receive VALUES from subprograms called in the main subprogram. These values are then passed into other subprograms via parameters. 2. Be able to declare and use IN and IN OUT parameters to pass values between subprograms. ===> Give an overall view of how these parameters fit into the design of the program. You may want to use the "main subprogram" or " supervisor" point of view. ===> Example: The supervisor (the main subprogram) calls subprogram READ_INFO. READ_INFO requires nothing from the supervisor to perform its task and the supervisor doesn't even know how the task is accomplished. The supervisor is just expecting some VALUES to come from the invoked subprogram. Once the subprogram is finished, the supervisor is now holding the values passed back in main subprogram variables. It passes copies of these values into subprogram PROCESS_DATA. This subprogram uses the values passed into it to accomplish its task and then passes more new values back to the supervisor. The supervisor is now holding values it has received form READ DATA and PROCESS DATA. The process continues . 3. Be able to draw IPO diagrams of subprograms receiving and passing back values. ===> IPO's show the communication with the invoking subprogram. IN PARAMETERS "' OUT PARAMETERS Note: if the parameter appears V on both sides, it --- is an IN/OUT name of the subprogram parameter. 88 4. Be able to use GET effectively in conjunction with prompts and echochecks to input INTEGERs and CHARACTERs into a subprogram. ===> Cover with simple examples. First explain that the instantiation of a new INTEGER IO package makes available not only PUT (introduced in lesson 6), but also GET. TEXT IO allows the reading of CHARACTERs with a GET. Remember to have them use STANDARD OUTPUT as the file to read from. ===> Insure they know the requirement for a prompt (to allow the user to know what he is supposed to input), and what types of errors may occur if the user inputs a type that is different than expected. 5. Know that an OUT parameter may not be used in a subprogram except to assign a value to it. ===> Once again, this is dependent on how the compiler implementor interpreted the MILSTD. You may assign a value to the parameter, yet you may not use that value in the subprogram (ie., as a variable to control a loop or even to write out the value). Thus, you may need to use a local variable to accomplish tasks in the subprogram and then assign the OUT parameter a value later. 6. Know that an IN OUT parameter may be used in any way in a subprogram. ===> Same as the VAR parameter in Pascal. 7. Be able to draw and use "structure charts." ===> C/W, pp 216-217 -- Show how we use this to give us a graphical image of our program and help us design our program. Daily Lab: LAB8.STU 89 LESSON 9 TITLE: Selection and Booleans SPECIFIC OBJECTIVES: 1. Know the six relational operators available in Ada and how to use them. ===> =, /=, >, = , We are now testing relationships between values, as they have already seen in math. Stress, however, that not all the [ relational operators are standard math symbols. 2. Understand what Boolean expressions are and how to evaluate them. ===> Show what makes up a simple boolean expression: The are each completely evaluated to yield a single r value. These values are then compared (must be of the same type) to yield the boolean value TRUE or FALSE. 3. Understand how to use the IF statement. ===> Explain with examples. You may want to use the standard flowchart structure to give them a graphical representation of what is happening. 4. Understand how to use IF-THEN-ELSE statement. ===> Remember that (contrary to Pascal's rule) a semicolon is rquired after each statement and thus one occurs directly before the ELSE. 5. Understand how to use the IF-THEN-ELSIF. ===> This is just an abbreviation of ELSE IF . again give examples. Once 6. Know how to use the logical operators AND, OR, XOR and NOT. ===> Show the truth tables and give examples. Emphasize that the logical operators only work on TRUE/FALSE values and that parentheses should be used to ensure the proper order of evaluation. AND THEN, OR ELSE, IN and NOT IN are not introduced. The first two may be looked at later and the last two when and if sets are introduced. 7. Be able to use and evaluate compound Boolean expressions . 90 ===> First show the rules of precedence: ** abs not * I mod rem + - = /= < >= and or xor ===> Examples are once again the best way to show this. One common student error is leaving off the parentheses if they are needed. For example --- HOURS > 40 or not OVERTIME < 10 --- the precedence rules show that not OVERTIME should be evaluated first which obviously doesn't make sense. 8. Understand the advantage of using IF-THEN-ELSIF instead of numerous IF-THENs. ===> if then; else ; end if; if then; if then; ===> On the average check N/2 conditions versus N conditions in the second case. We can also take care of possible errors easier. Daily Lab: LAB9.STU 91 LESSON 10 TITLE: CASE Statement SPECIFIC OBJECTIVES: 1. Be able to use the CASE statement effectively. ===> First show that a CASE statement is just a mul tiway selection where only one path is taken. Show that the case selector is evaluated (yielding a single value) and the "list" of values is searched until the selector's value is found. If the list is not all inclusive of possible values the type of the case selector may take on, a WHEN OTHERS is required. This will take care of the times when the selector's value is not found in the list. 2. Know when to use a CASE statement in place of an IF-THENELSIF statement and when not to. ===> A CASE statement is used when the possible values the selector can evaluate to is discrete (and scalar). The IF statement must be used for other types of situations. For example, a range of real values or complex logical expressions. ===> Show an example that has both single values on a line and several values on a line. For example: case GRADE is when 'A' => put line (standard_output, "This is an excellent grade. "); [ when 'B' => put line (standard_output, "This is a very good grade."); when 'C' => put line (standard_output, "This is an average grade."); when 'D'I 'F' => put_line (standard_output,"You had better work!"); when others=> put_line (standard_output,"This is an invalid grade."); end case; 3. Know that the expression in the CASE statement must evaluate to a discrete value. ===> Discussed above. 5. Know how to use the WHEN OTHERS clause in a CASE statement. ===> Discussed ·above. Daily Lab: LAB10.STU 92 LESSON 11 TITLE: EXAM #1 SPECIFIC OBJECTIVES: 65% Ada, the editor, and operating system commands 35% literacy 93 LESSON 12 TITLE: Problem Solving Formalized SPECIFIC OBJECTIVES: 1. Know the major steps in the "Problem Solving Methodology" as given in appendix 2. ===> Cover Appendix 2. 2. Understand the concept of "deskchecking" and be able to deskcheck an Ada program. ===>This should just be a review (ie., we are just formalizing the name). 3. Appreciate the need for program documentation and be able to document a program in accordance with Appendix 3. ===> c;w, p 171 -- Stress that documentation is not only for the programmer but for those who later need to use or review the program. Note: The "Problem solving Methodology" handout is located in Appendix 2. This ccontains the complete methodology plus an exxample. The example will be the decomposition of a lab they have already seen. (LAB9) Daily Lab: incomplete. Finish up any previous daily labs that are 94 LESSON 13 TITLE: FLOAT and BOOLEAN variables SPECIFIC OBJECTIVES: 1. Be able to declare and use FLOAT and BOOLEAN variables correctly. ===> Cover examples. Show the legal values that may be stored in each type of variable. Let them know that these variables may be used in the same places as INTEGER and CHARACTER (main subprogram variables, parameters, etc.) . Also show how we can use just the boolean variable where boolean expressions are required (IF statements). Many students will want to write = TRUE. ===> Possible example: AGE : integer; TEMP : float; TURKEY, BOO : boolean; Which assignment statements are legal ? TEMP .- 99.2; TEMP := • 7; TEMP .- 13 0; TURKEY .- true; BOO 0- "FALSE"; TURKEY .- 8 > 6; BOO .- 6 3; TEMP .- 17; TEMP .- AGE; TEMP .·-- AGE I 3.0; TEMP 0- float (AGE I 3 0 .- 0); TEMP ·.-- float (AGE I 3); 2. Know how to convert the value in a bariable of type INTEGER into .a value of type FLOAT and be able to use this in an assignment statement. ===> Using float (integer expression) . Also show that we must accomplish this type conversion if we are using real operations. For example: TEMP := float (AGE) 1 3.0; 3. Know that the arithmetic operators REM and MOD are not applicable to variables of type FLOAT. 4. Be able to instantiate a new FLOAT IO package for the predefined type FLOAT. ===> package REAL_IO is new FLOAT IO (FLOAT); use REAL_IO; 95 5. Be able to input and output FLOATs in a readable form using fieldwidths. ·===> Once the package is instantiated and made visible, GET may be used as it was with INTEGERs. PUT needs some additional information. put (standard output, , , ); since we will normally want our reals to be output without using scientific format, will be zero. put (standard_output, TEMPERATURE, 3, 1, 0); output from DDD.D Daily Lab: LAB13.STU 96 LESSON 14 TITLE: WHILE Loops and the "Trailer" Technique SPECIFIC OBJECTIVES: 1. Understand the concept of iteration. ===> Repeat a task 0 or more times. 2. Understand the "basic" loop and how it may result in an infinite loop. ===> First explain what an infinite loop is. ===> Example: loop; end loop; --without using an EXIT statement. 3. Appreciate the EXIT statement and the reasons why it will not be used in our course. ===> Make them aware that this is available. very special cases is the EXIT needed. readability normally suffers. Stress that only in If it is used, 4. Be able to use the WHILE loop effectively and understand in which situations it is useful. ===> First show the diagram of the control structure. Show that the boolean expression is the same type of expression as used in the IF statements. Stress that the boolean expression is tested at the beginning of the loop and if true, the WHOLE loop body is executed before the test is made again. A common student error is believing that as soon as the condition turns false (even if they are in the middle of the loop), the loop stops. ===> Show how the WHILE loop works and stress the following points: a. When the WHILE loop completes, the test is known to be false. b. The statement(s) being repeated must bring the BE closer to being false. c. To "test" the WHILE loop, test a few iterations at the beginnig, middle, and end. ===> Discuss some simple examples. For instance: X : integer; X := 0; while X < 11 97 loop X := X + 2; end loop; What happens? Use boxes, columns, etc. to keep track of the value of X. What happens if the BE is X /= 11? What happens if the BE is X > 11? 5. Understand the difference between an IF-THEN statement and a WHILE statement, and when each should be used. ===> Show the difference using previous examples. Stress that an IF statement's BE is checked one time. The WHILE loop BE is checked one or more times. The loop continues until the BE turns false. 6. Be able to use the "Trailer" Technique effectively. ===> The trailer technique is when we use the WHILE loop to accomplish a task while a value remains inside a specified range. The value to be checked is updated at the end of the loop. In other words, we don't know how many times the loop will be accomplished when we enter the loop. Something external (many times the user at the terminal) is controlling the iteration. ===> Example: SUM, NUMBER integer; SUM := O; put_line (standard_output,"Please enter the first test score."); [ put line (standard output,"A valid score is between 0 and 100."); put=line (standard=output,"Enter a negative number to stop."); put_line (standard_output,"entering scores."); · get (standard input,NUMBER); while (NUMBER->= 0) and (NUMBER Questions to ask about the above code: 1. Why is SUM initialized to 0? 2. Where else could SUM have been set to 0? 3. Why do we read the first score outside of the loop? 4. What happens if you read in a score at the beginning instead of the end of the loop? 7. Know the meaning of the acronym 'ITEM'. ===> We use this to insure that the students understand how loops 98 are accomplished. ===> Initialize -- the variable controlling the loop. Test -- the control variable. Execute -- the body of the loop if the test is true. Modify -- the control variable. 8. Be able to apply ITEM to control the WHILE loop. ===> Point out the statements in your examples that correspond to ITEM. Stress that the PROGRAMMER must accomplish each of these steps. 9. Know the common error which results in an "infinite loop" when using the while loop. ===> Show that failure to modify the control variable is the common error. Illustrate with examples. Daily Lab: LAB14.STU 99 LESSON 15 TITLE: Computer Exercise #1 HOMEWORK: Prior to class review Appendix 2 -- "Problem Solving Methodology" and read the Computer Exercise #1 handout. SPECIFIC OBJECTIVES: 1. Be able to use the problem solving methodology to program a solution to Computer Exercise #1. 2. Be able to document a program IAW Appendix 3. Daily Lab: The lab time will now be used for Computer Exercise #1. 100 LESSON 16 TITLE: FOR Loops and the "Header" Technique SPECIFIC OBJECTIVES: 1. Be able to use the FOR loop (counting loop) effectively and understand in which situations it is useful. ===> We will introduce just the simple counting loop: for in . loop end loop; ===> You should also introduce -- IN REVERSE. ===> Some points to stress: a. Just a special case of the WHILE loop (could be done with a WHILE loop). To use the counting loop, you must know exactly how many times you want the loop to be accomplished. b. does not need to be declared and it is only "valid" for the duration of the loop. It may not be used after the loop and it may not be assigned a value inside the loop. It may only be used in the loop (but not assigned a value) . c. and expressions are evaluated ONCE at the beginning of loop execution and must be a scalar type (normally INTEGERs, but may also be CHARACTERs). If variables in or change inside the loop, the number of times the loop is accomplished will not change. 2. Be able to decide in a given situation if the FOR or WHILE loop is appropriate. ===> T o use a FOR (counting) loop, you must somehow know (from another procedure, a GET, a constant, etc.) how many times you want the loop to be accomplished. You cannot get into an infinite loop in a FOR loop and you may with a WHILE loop. 3. Know how ITEM applies to a FOR loop. ===> Initialize, Test, and Modify is done in the first line of the FOR loop. Stress that the Modify is done automatically at the end of each iteration. For integer loop variables, the modification is by 1 (or -1 if using REVERSE) . 4. Be able to use the "Header" Technique effectively. ===> The "header" technique is when we find out before the loop how many times the loop will be accomplished. We use the FOR 101 loop to implement the "header" technique. ===> Example: SUM, SCORE float; NUM SCORES : integer; SUM := O; put_line (standard_output,"Input the number of scores to be get (standard output, NUM SCORES ); for I in 1 . -NUM SCORESloop put (standard_output,"Please input score#:"); summed:"); put (standard_ output, I, 2); may use the loop control variable new_line (standard_output); get (standard_input,SCORE ); SUM : = SUM + SCORE; end loop; put_line (standard_output, 11Number of scores put_line (standard_output," --- put (standard_output, NUM_SCORES, 7, 2, 0 ); put (standard output, SUM, 24, 2, 0 ); Sum of Scores"); --- "); 5. Know the three type of contrrol structures in structured programming and which Ada statements implement each. ===> C/W, p 174 -- We havve now covered all the structures Sequence, Selection (IF and CASE), Iteration (FOR and WHILE). Emphasize that these structures are considered the "basic building blocks of all program construction." 6. Appreciate the (four) results of "structured programming." ===> c;w, p 215 a. Increase programmer productivity. b. Reduce the time required to test programs. c. Increase the clarity and readability of programs. d. Decrease the time required to maintain programs. 7. Know the definition of Top-Down design. ===> C/W, p 215 -- First identify basic program function. These functions are divided into smaller and smaller subfunctions called modules (subprograms) until they are easy to solve. Show how structured charts graphically describe Top-Down design. This should just be giving a formal name to something they have been (hopefully) practicing. 8. Appreciate the concepts of "coupling" and "cohesion". ===> c;w, p 216 -- coupling -- the measure of the strength of the relationship between two subprograms. We want weak coupling so that modules are independent. This is why we use the "rule" that the only variables used in a subprogram are those declared 102 locally or in the formal parameter list. Cohesion -- the measure of the inner strength of a module. We desire strong cohesion, ie., accomplish a single task. 9. Appreciate the concept of "pseudocode" and the advantages of its use. ===> C/W ' · p 219 an English-like way of representing the problem solving steps reqquired to accomplish a particular task. We have been doing this all along. We are just formalizing the name. 103 LESSON 17 TITLE: Literacy SPECIFIC OBJECTIVES: 1. More literacy (this gives time for answering questions on the computer exercise) . 104 LESSON 18 TITLE: Algorithms SPECIFIC OBJECTIVES: 1. Know the definition of an "algorithm". ===> A group of precisely defined, unambiguous statements that effectively solve a problem in a finite number of steps. 2. Know the four characteristics of any good algori thin and understand why they are important. ===> finite, precisely defined, unambiguous, and effective. 3. Be able to find the average of a group of numbers. ===> They have already been introduced to this in LAB14. Go over the concept. Show how the computer is doing what a human would do without pencil and paper. Specifically ask questions such as: a. Why can't we read in all the scores first, then add them together, and then find the average, instead of keeping a running total? b. Would we want to use the Header or Trailer technique? 4. Be able to find the maximum and/or minimum value of a group of numbers. ===> Read a list of numbers and ask the students to tell you the minimum number. Then ask them to PRECISELY tell you how they arrived at that minimum. This will hopefully show how the algorithm may be accomplished in Ada. Go over the following FIND_MAX procedure. Stress that the only real difference between FIND MAX and a 11 FIND_MIN11 (besides appropriate changing of names) is the comparison in the IF statement. You may want to have your students change the procedure to use the trailer technique (given a range of legal scores). ===> Example: procedure FIND MAX ( MAXIMUM out integer ) is NUM SCORES MAX, SCORE integer; float; --must have MAX since MAXIMUM cannot --be used for comparisons, etc. Really --depends on Ada implementation used. begin -- FIND MAX put_line (standard_output,"Enter the number of test scores:"); get (standard_input, NUM_SCORES); new line (standard output, 2); put=line (standard=output,"Enter Score #1: 11 ); 105 get (standard_input, SCORE); --could also - get {MAX); MAX : = SCORE; for SCORE COUNT in 2 . NUM SCORES loop put_line (standard_output,"Enter Score: "); get (standard input, SCORE); if SCORE > MAX then MAX := SCORE; end if; end loop; MAXIMUM : = MAX; end FIND_MAX; 106 LESSON 19 TITLE: Functions SPECIFIC OBJECTIVES: 1. Understand the concept of a predefined function and be able to use the predefined function 'ABS'. ===> You must first explain the concept of a function versus a procedure. Then explain that certain commonly used functions have already been written and tested and may be used by instantiating the package which contains that function you want to be used. The package STANDARD (which is always available) contains the function ABS. Show how this would be used. 2. Know where a function must be invoked. ===> Stress that a function returns a VALUE of a particular type through its name and therefore, must be used inside an expression. Show the difference between invoking a function and a procedure. Example: abs (-4); is ust like using: 4; which means nothing by itself. 3. Know when it is appropriate to use user-defined functions. ===> Basically used when a subprogram returns only a single value. 4. Be able to write and invoke user-defined functions. ===> It is helpful to spend some time comparing functions and procedures. Write an easy procedure that returns one value and then a function that performs the same task. Use each of these to solve the same problem. ===> Example: procedure CUBE ( NUMBER in float; RESULT begin -- CUBE RESULT := NUMBER * NUMBER * NUMBER; end CUBE; out float ) is function CUBE ( NUMBER in float ) return float is begin -- CUBE return NUMBER * NUMBER * NUMBER; end CUBE; 107 Now solve the following equation for X: 3 3 X = A = B where A = 4 and B = 5. Using a procedure, the code would be CUBE ( 4, A ); CUBE ( 5, B ); X := A + B; Using the function, the code would be X:= CUBE (4) +CUBE (5); As in this example, a function may often be more convenient and intuitiveto use. This example also shows that a . function returns a value when invoked and cannot be used as a statement by itself. 5. Know the three important items to remember when writing a ( user-defined function. ===> a. b. c. only IN parameters will be used. a function must have a return type. a value must be "returned" using the return statement. 6. Know the two common errors made when writing a function. ===> syntax error -- not giving a function a return type ===> forgetting to return a value at the end of the function 7. Appreciate the concept of recursion and what may happen when recursion is inadvertently used. ===> The name of the function is used inside of the function. The function is calling itself. Stress that recursion is only used in special cases. LAB19 shows an example of the recursive function FACTORIAL. 8. Be able to draw IPO diagrams for user-defined functions. ===> Same concept at procedures, except no OUT or IN OUT parameters. Daily Lab: LAB19 . STU 108 LESSON 20 TITLE: EXAM #2 TOPICS COVERED: 65% Ada and Problem Solving 35% literacy 109 LESSON 21 TITLE: Constants, Numbers, Types, Subranges, Subtypes, and One-Dimensional Arrays SPECIFIC OBJECTIVES: 1. Be able to declare constantsand numbers and be able to use them effectively. ===> Show how and where constants and numbers are declared. Distinguish between a "number declaration" and "constant declaration." A constant declaration has a type specified while a number declaration doesn't. The number declaration is what will normally be used (ie., giving a name to a commonly used value). A constant declaration may be assignedan initial value DURING the execution of the program. A number .declaration must have a static expression at compile time. Point out that the value cannot be changed in the program. 2. Be able to declare subranges of INTEGERs and FLOATs. ===> Just introduce subranges as below: WATER_TEMPERATURE : integer range 32 . 212; Explain that the declared variable is just a subtype (not a different type) of the base type. Tell them that if a value outside the range is assigned to the variable, an execution error (constraint error) occurs. 3. Be able to use the predefined subtypes NATURAL and POSITIVE. ===> Explain that these are in package STANDARD and may be used when logically called for. Natural - 0 to integer'last Positive - 1 to integer'last 4. Know the difference between a constantjnumber and a subrange and know to use them together in an Ada program. ===> A subrange constrains the possible values that a variable of that type can take on. A constant/number gives a name to a value (this value c'an't be changed). They are used together to make programs more meaningful, easier to read and change. ===> Use an example. One example using number declarations: MAX_SCORE : constant := 100.0; MAX OIL PRESSURE constant := 75; MIN_OIL_PRESSURE : constant := 15; OIL_PRESSURE : integer range MAX_OIL_PRESSURE . MIN_OIL_PRESSURE; SCORE: float range O •• MAX_SCORE; 5. Know the two situations where an array is useful. 110 ===> When we want to store a large number of RELATED values andjor we want to use the values more than once. 6. Be able to use an array effectively. ===> First cover the concept of an array. Then cover how to declare an array type and an array variable of that type. Stress the concept of declaring a type versus declaring a variable of that type. Students will tend to confuse array types and array variables. ===> Explain that when a type is declared, nothing is actually created. A type just gives us the CAPABILITY (a blueprint) to create a structure. When we declare a variable of that type, we actually CREATE the structure and give it a name. · Once it is created, itcan then be used in the program. ===> show that an array is just a collection of variable locations that have the same overall name and different indexes. All the locations hold the same type of value (INTEGER, FLOAT, BOOLEAN, or CHARACTER). ===> Example: MAX STUDENTS : constant := 4417; type GRADE ARRAY is array ( 1 . MAX STUDENTS) of float; GRADES : GRADE_ARRAY; ===> Other points to bring out: a. You may use arrays as formal and actual parameters. b. You may not change the size of the array during the running of the program. c. By using a constant as above, changing the size of an array between runs becomes much easier. d. A single array element is just like a single variable. It may be used in the same places as a single variable (expressions, assignment statement, gets, puts with fieldwidths, etc.) . 7. Understand why arrays and iteration are useful together. ===> This concept may be demonstrated by example. Suppose we have 10 scores stored in the integer variables SCORE1, SCORE2, By puttng the values in an array, would we simplify the problem? Simple variables require a different name to access each value. Arrays allow us to use the same name but differnt indices (which can be a variable that is the control variable in a loop). 8. Know why it is advantageous to read values into an array in a separate module. ===> Relaate this to the concept of Top-down design and stepwise refinedment, where each subprogram performs a single task. 111 9. Be able to find the average, maximum, and minimum values of a group of number using arrays. ===> Once again show by example. Show how easy these operations are with iteration. Show that we can either (when finding max or min), save the actual max or min value, or save WHERE the max or min value is. Show examples of both. 10. Understand how the execution error "subscript out of range" is caused. ===> This error message may have to be changed depending on the compiler error message. The concept is that you are telling the computer to use a location that doesn't exist. 112 TITLE: LESSON 22 Review of Functions, Types, Subranges, Subtypes, Constants, and One-Dimensional Arrays SPECIFIC OBJECTIVES: 1. Be able to write and invoke user-defined functions correctly. 2. Be able to declare an array type and an array variable of that type. 3. Be able to use an array effectively. 4. Be able to find the average, maximum, and minimum values of a group of numbers using arrays. 5. Be able to eclare constants and use them effectively. 6. Be able to declare subranges and use them effectively. 113 LESSON 23 TITLE: Searching SPECIFIC OBJECTIVES: 1. Know the definition of a "sequential search." ===> Checking every element, starting at the first, then the second, etc., until we find what we are looking for. Point out that the main advatage of the sequential search is simplicity. Also point out that it is relatively slow in comparison to other search algorithms they won't see in this course. 2. Be able to recognize situations wher a search is required. ===> Show by example. Also stress thatwe are normally more interested in WHERE the value we were searching for is, versus WHAT the value is. Give an example such as: We have two arrays, one with a student number (integer) and one r with a GPA (real). We want to find the GPA for a particular student. We find the student's number and remember where it was (the index). We then can go to the GPA array and get the student's GPA. This also introduces the concept of parallel arrays (see objective #4). 3. Understand how logic errors are caused and know how to go about correcting them. ===> Review what a logic error is. Stress that the programmer [ MUST look at their output to see if it seems correct. For example, assume your program was to figure the speed of a car given the distance it traveled and hours it took (assuming these values were realistic) . If the speed that was printed was 11000 mph, ther is something obviously wrong in the logic. ===> Then present some debugging strategies: a. The importance of deskchecking. b. The use of debug PUT statements to keep track of variable values, wher execution currently is, etc. c. Isolating the procedure which is causing the problem with debug statement. d. Tracking backwards from the point at which the first erroneous output occurred. 4. KNow what "parallel arrays" are and what they are used for. ===> See objective #2. 114 LESSON 24 TITLE: Sorting SPECIFIC OBJECTIVES: 1. Know the role "searching" accomplishes in a "sort". ===> First explain the difference in an ascending and descending sort. Give some short examples of sorted lists. ===> The sort we will use is the "selection" sort. This sort is described below in pseudocode: Start at the first location in the array. Find the location of the smallest (or largest) element in the array. Remember the location. Switch the element in location 1 and the smallest element. We now start our search for the smallest element at location 2. Once we find it, we switch the element in location 2 and the element we we found. We continue this for location 3 to n. ===> Point out that this sort is just the performance of two steps (find_smalljfind_large and switch) over and over until the sort is accomplished. Point out also that the find procedure wants the LOCATION of the smallest/largest value, not the actual value. 2. Be able to find the location (index) of the smallest or largest item in an array. ===> Accomplished by example. 3. Be able to switch information between two locations in an array. ===> Show with pictures the problem that many students encounter with their first try at a switch: EXAMPLE ( ) EXAMPLE () := EXAMPLE (); := EXAMPLE ( ); This should make it obvious that a temporary location is needed to hold one of the values. Stress that this temporary location IS NOT AN ARRAY, but a variable of the same type as the base type of the array. ===> Also discuss sorting parallel arrays: a. Only one array needs to be passed into the search procedure. b. ALL arrays must be passed into the switch procedure. c. Different temporary variables must be declared if and only if the different arrays are of diffferent base types. 115 4. Understand the simple difference in logic to effect r ascending and descending sorts. ===> Point out that the only difference is the relational operator in the search procedure. [ 5. Know how to use "parallel arrays." ===> Cover filling, sorting, searching, and printing parallel arrays. We will use parallel arrays on Computer Exercise #2. 116 LESSON 25 TITLE: COMPUTER EXERCISE #2 SPECIFIC OBJECTIVES: Read computer exercise #2. Be ready to ask any questions when your instructor review the exercise. 117 LESSON 26 TITLE: Review: Sorting and Searchin SPECIFIC OBJECTIVES: 1. Be able to accomplish a "sort" using Ada. 2. 3. Be able to accomplish a "search" using Ada. Be able to sort parallel arrays. 118 LESSON 27 TITLE: Two-Dimensional Arrays and Variables of type STRING SPECIFIC OBJECTIVES: 1. Know how to declare, access, and use two-dimensional arrays effectively. ===> Just as with 1-D arrays, we must declare a 2-D array before you use it. To create a STRUCTURE of this type, you must have a new TYPE. Once the new type is declared, this gives us the CAPABILITY to create as many of the actual structures as we need. Additionally, it gives us the ability to pass structures of this type in and out of procedures via parameters. ===> Present the 2-D array as it logically looks (a table, grid, matrix, etc.) Emphasize that each location in the array is of the same BASE type (all integers, floats, etc.). If there are values of different types that need to be stored logically together, then parallel arrays should be used when using languages which don't support the RECORD structure. We will introduce the RECORD structure in lesson 29. ===> Show how to access the locations for assigning values. 2. Be able to read data into a two-dimensional array. ===> Reading data from an external file will be covered next lesson. Therefore, just explain how to assign a value using the GET statement (from the keyboard). 3. Be able to write out the contents of two-dimensional arrays. ===> Insure they understand that an array location is just like a simple variable. They should alway use fieldwidths when writing out the value. 4. Understand that searching or sorting a two-dimensional array means searching or sortin based on a particular column. ===> Searching -- show that one normally specifies a column to search. Once this is done, this subscript remains constant and the search is just like a search of a 1-D array. ===> Sorting -- show that one normally specifies a column to sort the array on. The switch then switches all the columns. This is just like a series of parallel arrays. 5. Be able to search and sort a two-dimensional array. 6. Be able to use nested iteration effectively. ===> A good example to introduce the use of nested iteration is 119 to assign a zero to all the elements of a 2-D arrays. 7. Be able to use variables of type STRING. ===> This should be relatively easy since it is basically just a 1-D array of CHARACTER. Cover how to print them out, fill them up from the keyboard, etc. 120 LESSON 28 TITLE: Reading from External Data Files SPECIFIC OBJECTIVES: 1. Understand what an external data file is and what it is used for. ===> Relate that this is how most applications in the real world work with information. 2. Be able to write Ada subprograms that read information from an external data file. ===> Use a complete example to accomplish this objective. a. Create an external file using the text editor. Explain external files are set up in a particular format that the (programmer) must know. The format should make the external easy to read and modify from the program, AND easy to directly to (using a text editor). that user file add b. Once the external file is created, the Ada program may use the data in this file. The applicable Ada statements follow: one Declaration: 1) Main program declaration section -< internal program filename> file_type; Four executable statements: 2) Associate the internal file name with the external file, opens the external file up for reading, END OF FILE is set to false, and the "internal pointe0• is set to row 1, column 1: open (, in file,""); 3) Read a value from the external file: get (,); 4) Control the "carriage return" in the external file. skip line (); 5) Sever -the association with the external file and close the external file: close (); One Boolean function: 6) END_OF_LINE (); ===> With the above, the student may effectively use external files. There are many other statements that are available, however, the above set allows the student to concentrate on the essentials of reading data. ===> The close statement is used to reinforce the concept that once you have read the data from the file into your data 121 structure in the program, you don't have to use the external data file again in the program. ===> Insure they understand that leaving out the in the GET, SKIP LINE, END OF LINE, etc., will cause the program to use STANDARD INPUT. This is the reason that specifying the filename frontthe start of the course is taught. ===> Emphasize that the programmer must know the format of the external file so they can explicitly control the "carriage return" and control what is being read. A good example is a procedure which reads in numbers from an external data file into an array (use of 2-D arrays and nested iteration reinforced) . 3. Understand how END OF FILE can be used in the trailer technique, and be able touse-it effectively to read information from a file. ===> Point out that we can use the trailer technique (not knowing how many lines of data are available) AND that the ITEM check must stell be accomplished: Initialize --OPEN (, in file,""); Test --WHILE NOT END_OF_LINE (); Execute/Modify GET and SKIP LINE 4. Understand that we are reading information from a file sequentially. ===> Tell them that this is not the only way to read data, just the easiest at this point. ===> OTHER POINTS: a. You don't GET from an array. Once the data is read from an external file into an array, the file is not used again from the program's run. The use of CLOSE will help reinforce this concept. b. You normally read a file left to right, top to bottom. c. You should explicitly control when to go to the next line in a file. d. Insure they know how the computer figures what to read from a file into a variable. Depends on the type of the variable (C~CTER, FLOAT, INTEGER, STRING, etc.). Go over examples of each. 122 LESSON 29 TITLE: Records and Writing to External Files SPECIFIC OBJECTIVES: 1. Understand the concept of a record. ===> Once again cover with an example. Show how the use of parallel arrays in a program may be changed to the use of a record. A complete example is needed. 2. Understand the difference between an array of a particular predefined type (INTEGER, FLOAT, BOOLEAN, or CHARACTER) and an array of records and when each should be used. ===> Cover by example. 3. Be able to sort and search an array of records. ===> Show that their isn't really much of a difference (except that the Switch is MUCH easier). 4. Be able to write output to an external file other than STANDARD OUTPUT. ===> Cover how to open a new external file -- open (, out file,""); ===> cover how to write to an external file. 123 LESSON 30 TITLE: Recursion and Sets SPECIFIC OBJECTIVES: 1. Understand what recursion is and what it is used for. ===> They have already been introduced to recursion in functions. Recursion should just be introduced. They will not have to use it in any programs. 2. Understand what sets are and how they are used. ===> Same as objective #1. Note: Review LAB19.STU for recursion. 124 LESSON 31 TITLE: Ada Review SPECIFIC OBJECTIVES: 1. Review the concepts of the Ada language covered thus far. 2. Appreciate that only part of the Ada language has been covered and that Ada is a full-bodied language able to accomplish many tasks. ===> Relate that it may be used in many different tasks. 125 LESSON 32 TITLE: EXAM #3 SPECIFIC OBJECTIVES: 65% Ada and Problem Solving 35% literacy 126 LESSON 33 TITLE: Computer Exercise #3 SPECIFIC OBJECTIVES: Read Computer Exercise #3. Be ready to ask any questions when your instructor review the exercise. ===> This exercise will be fairly easy. They will just be converting Computer Exercise #2 (using parallel arrays) to use records, strings, and writing the output to an external file. 127 Section III. Lab Activities 128 Section III. Lab activities III.I. Daily labs III.II. Exercises overview of computer exercises Exercise 1 : Spaceship docking simulation Exercise 2 : Reports for air support Exercise 3 : Modification of exercise 2 III.III. Lesson by lesson program listings 1 III.I Daily Labs For each daily lab in this section, there are two "versions." The first (LAB.STU) is the actual file the students copy from a master directory. Following this is the completed output format. The actual administration of daily labs is a four step process. 1. The student copies the daily lab from a master diskette at least the day before class meets. To accomplish the lab they follow the lab's instructions contained in the file. 2. During class, the instructor covers the material for the day. The student who has read the material and lab instructions will be prepared to ask any questions which need to be answered. 3. During lab time, the student first runs an approved solution to the lab. This not only shows the "desired" output format but also proves that the lab can be done. 4. The student accomplishes the lab during the remainder of the lab period (and during outside time if need be). III.II Exercises OVERVIEW OF COMPUTER EXERCISES The computer exercises are used to reinforce the concepts taught during the previous block of lessons and to give the students practice in problem solving and programming. Each exercise has an approved solution which may be run (they only have access to an executable object file) by the student before they start work on it. I have found this exercise improves their output since the "approved solution" shows them an example of "good" output. The main Ada topics covered on each exercise are covered below. Computer Exercise #1 Use of Variables -- integer, float, and boolean Use of IN, OUT, IN OUT parameters Use of WHILE Loop, IF statement, and elementary statements such as assignment statements and subprogram calls computer Exercise #2 All topics from Computer Exercise #1 Reading Data from External files Searching Sorting Use of parallel arrays (both 1 and 2-D) with base types of the array being character, float, and integer 2 Computer Exercise i3 All topics from Computer Exercise #1 and #2 Writing to External files Use of the Record Data Structure Use of the STRING variable type 3 OBJECTIVE COMPUTER EXERCISE #1 Spaceship docking simulation You are to develop a program which will simulate the docking of a spaceship and an orbiting lab. The orbiting lab has two crewmembers and they have an EMERGENCY! They only have 45 seconds of oxygen left and the ship must dock with their craft before that time expires. The ship, on the other hand, has only 5000 kgs of fuel left and needs at least 100 kgs to effect a reentry to the atmosphere. The ship has an on-board computer which has malfunctioned. The computer will control steering to the lab through the radar link, however it has lost the capability to control the velocity through the throttle link. This is where the pilot (who is using your simulation) comes in, since the pilot must now control the firing of the rockets. Through the use of the information which you will present to the pilot each half second of "mission time," the pilot will enter a throttle setting for the next half second of rocket bu; http://uab.contentdm.oclc.org/cdm/ref/collection/uab_ece/id/55
-
13
Authors:
Source: International Review of Electrical Engineering; Jan/Feb2018, Vol. 13 Issue 1, p15-22, 8p, 1 Diagram, 2 Charts, 4 Graphs
-
14
Authors:
Source: Practical Aspects of Declarative Languages (9783540309475). 2005, p199-214. 16p.
-
15
Authors:
Source: Fundamenta Informaticae; 2016, Vol. 145 Issue 4, p471-483, 13p
-
16
Contributors: Frankl, P
Source: Other Information: Thesis (Ph. D.)
File Description: Medium: X; Size: Pages: 208
Access URL: http://www.osti.gov/scitech/biblio/6579274
-
17
Authors:
Source: IEEE Transactions on Pattern Analysis & Machine Intelligence; Feb2014, Vol. 36 Issue 2, p222-234, 13p
-
18
Authors: et al.
Source: IEEE Transactions on Knowledge & Data Engineering; Jun2014, Vol. 26 Issue 6, p1464-1478, 15p
-
19
-
20
Authors: et al.
Source: IEEE Transactions on Knowledge & Data Engineering; Jun2014, Vol. 26 Issue 6, p1532-1543, 12p
Full Text Finder
Nájsť tento článok vo Web of Science