Computer Science 1 1/19/2011 On the record (paper) write the following

Slides:



Advertisements
Similar presentations
Chapter 2: Modularization
Advertisements

© Dolinski This presentation will help you with the database section of your coursework. It will cover: – What you need to do.
Overview C programming Environment C Global Variables C Local Variables Memory Map for a C Function C Activation Records Example Compilation.
Surname:Brown Forename:James Form:7B Date of Birth: Telephone:
Writing Your Resume A resume is a well-organized document which gives factual information about you and lists your strengths, accomplishments, skills,
Sha Tin Methodist College F.4 Computer Studies Pascal Programming.
Computer Science 1 How do you store a bunch of similar stuff?
Simple “VICO” (“VIPO”) Programs (Variables, Input, Calculating or Processing, Output)
Computer Science 2 Arrays of Records. First Record Program Input an unknown number of Team Names, School names, and Total scores. (While loop) –Output:
My Favorite Song “Song Title” Name. Information about the Artist The five ws about the artist Who they are What type of music they make When did the y.
String Concepts In general, a string is a series of characters treated as a unit. Computer science has long recognized the importance of strings, but it.
Run-Time Storage Organization
Run-Time Storage Organization
A solution to a list of records
The Maker.
(c)opyright Brent M. Dingle 2001
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Program options Write a program for one of the following
Computer Science Dynamics.
Use proper case (ie Caps for the beginnings of words)
How do you store a bunch of similar stuff?
Chapter 8 Arrays Objectives
Computer Science II First With files.
Computer Science II First With files.
Review Dry Run Taking Names Online time Math is Good
Computer Science 2 Arrays of Records.
Computer Science 1 Get out your notebook
Computer Science 2 Review the Bubble Sort
Continue on the Array of Records program
Insertion Sort Quiz on Thursday.
Computer Science 2 Arrays of Records.
Computer Science 2 Getting an unknown # of …. Into an array.
Topics discussed in this section:
Computer Science Dynamics.
Wednesday September 28th
Computer Science Sorting.
Computer Science 2 Arrays of Records.
Arrays Topics Definition of a Data Structure Definition of an Array
How do you store a bunch of similar stuff?
Computer Science Sorting Pre-Test Discussion/program
Computer Science 2 Tally Arrays 2/4/2016.
CS 2 Records 2/22/2018.
Chapter 8 Arrays Objectives
AP Java 9/21/2018.
Computer Science II Second With files.
Why Computer Science? “The United States currently has more than 494,000 unfilled computing jobs, but only 43,000 computer science graduates to fill those.
Sorting Develop a sorting algorithm
Continue with Life, Magic and Catch -up
Computer Science 2 More Trees.
Computer Science 1 while
Computer Science 1 For..do loop Dry Run Take notes on the For loop
How do you store a bunch of similar stuff?
Welcome Back CS 2 2/4/2013 On the record (paper) write the following
Introduction to Python
Continue on the Valentines program
Time to finish first stack program
Program options Write a program for one of the following
Computer Science 1 while
Hint idea 2 Split into shorter tasks like this.
Computer Science 1 while
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
Dry Run Fix it Write a program
Algorithms For use in Unit 2 Exam.
Arrays Topics Definition of a Data Structure Definition of an Array
Computer Science
Selection Sort Insertion Sort if time
A bit of Review Review, Dry Run, Program.
Year 8 Computer Science Digital Portfolio
Computer Science II First With files.
Presentation transcript:

Computer Science 1 1/19/2011 On the record (paper) write the following Name:______________ Farthest from Salem:____________ Favorite Food: _____________ Favorite College: _____________ Top three college majors:_______________

Computer Science 2 Today: Understand how to save different kinds of information about a person in a record. On the record (paper) write the following Name:______________ Farthest from Salem:____________ Favorite Food: _____________ Favorite College: _____________ Top three college majors:_______________

What would you use if… You needed to store someone’s name, age, and phone number? What about name, strength, skills and position? What about a recipe: Title, Ingredients, instructions, … How about a song title, length of the song, artist name, ranking on your personal favorites list, … Pascal has a ‘data structure’ that can store more than one type of information in a single variable.

Program RecordsExample; type StudType = record name:string; age:integer; gpa:real; end; var Student1,Student2:Studtype; begin writeln(‘Please enter your name’); readln(Student1.name); writeln(‘Please enter your age’); readln(Student1.age); writeln(‘Please enter another name’); readln(Student2.name); writeln(‘Please enter another age’); readln(Student2.age); if (Student1.age) > (Student2.age) then writeln(Student1.name,’ is older’) else writeln(Student1.name, ‘ is not older ‘); end. Student1 Name:________ Age:_________ GPA:_________ Student2

Declarations and stuff In the Type section Rectype = record Field1:field1type; Field2, field3:field23type; … End; In the Var section Recordvariable:Rectype; In the Code Section Recordvariable.Field1:=…;

What do you think this will do? Program RecordsExample; type StudType = record name:string; age:integer; gpa:real; end; var Student1,Student2:Studtype; begin writeln(‘Please enter your name’); readln(Student1.name); writeln(‘Please enter your age’); readln(Student1.age); writeln(‘Please enter another name’); readln(Student2.name); writeln(‘Please enter another age’); readln(Student2.age); if (Student1.age) > (Student2.age) then writeln(Student1.name,’ is older’) else writeln(Student1.name, ‘ is not older ‘); Writeln(Student); end. Common errors Putting a ; here Forgetting the ‘end.’ What do you think this will do?

Write the declarations (Type and var) for a variable that needs to hold… Team Name, School, Total score (For a swim meet, wrestling meet, track meet, …) Project Leader name, Three goals (Sentences), Money allocated for the project, Project due date. Student name, Student ID number, Class schedule.

First Record Program Input an unknown number of Team Names, School names, and Total scores. (While loop) Output: The winning team. That is the team with the highest score. (If there is a tie, just show the first team with the top score.) (Note, you don’t need an array for this program.) Push: Same input as above, and show the schools with the top five scores. (You do need an array and a sort for this one.)