We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byEllie Merriman
Modified over 2 years ago
Files Using Sequential files (Flowchart example) © Juhani Välimäki 2003
Sequential files (in our flowcharts) Serial access: Can be read only from the beginning towards the end. Not possible to move backwards. File opened either for reading (R) or for writing (W). Reading only one record (=data compound) at a time or writing one data compound into the file. If the file was opened for writing it’s contains are emptied and whatever was inside will be lost. © Juhani Välimäki 2003
Example – Problem description We have a file called “grades”. It contains names of locations(like “London”) and the annual average temperature in centigrades Now we would like to convert the temperatures to the Fahrenheit-scale for some other marketing area. Names are good as they are (“London”). © Juhani Välimäki 2003
Example – Temperature conversion We read from the file “grades”. That file will be opened for reading (R). We read record by record to the data compound variable grade T_GRADE. We convert the centigrades Fahrenheit-degrees using formula F = centigrades * 1.8 + 32. We create a new variable temp T_TEMPERATURE, which will written to the output file. The result will be written to the file “temperatures”. That file was opened for writing (W). © Juhani Välimäki 2003
Example – Converter program DEFINITIONS grades sequential file TYPE T_GRADE location AN 20 celsius N 3 grade T_GRADE temperatures sequential file TYPE T_TEMPERATURE city AN 20 fahrenheit N 3 temp T_TEMPERATURE STAR T END READ grades -> grade temp.fahrenheit = grade.celsius * 1.8 + 32 OPEN grades(R), temperatures(W) NOT grades-EOF FALSE TRUE WRITE temp -> temperatures CLOSE grades, temperatures temp.city = grade.location © Juhani Välimäki 2003
Example – What happens in the program? grades ”London” ”Helsinki” 10 519”Agadir” ”New York” ”Bruexelles” 2315 117 ”Caraca s””Mani toba” temperatures ”London”50 ”London” 10 ”London” 50 grade T_GRADEtemp T_TEMPERATURE (assignment) temperatures sequential file TYYPPI T_TEMPERATURE city AN 20 fahrenheit N 3 city AN 20 fahrenheit N 3 grades sequential file TYYPPI T_GRADE location AN 20 celsius N 3 location AN 20 celsius N 3 READ WRITE © Juhani Välimäki 2003 (assigning the result of the conversion 10 x 1.8 + 32 = 50)
Example – What happens next? grades ”London” ”Helsinki” 10 5 19”Agadir” ”New York” ”Bruexelles” 2315 117 ”Caraca s””Mani toba” temperatures ”London” ”Helsinki” 50 41 ”Helsinki” 5 41 READ WRITE grade T_GRADEtemp T_TEMPERATURE (assignment) (assigning the result of the conversion 5 x 1.8 + 32 = 41) temperatures sequential file TYPE T_TEMPERATURE city AN 20 fahrenheit N 3 city AN 20 fahrenheit N 3 grades sequential file TYPE T_GRADE location AN 20 celsius N 3 location AN 20 celsius N 3 © Juhani Välimäki 2003
Real life: Files Files are simplified to make easier programs Might be possible to read and write to the same file. Might be possible to move backwards inside the file. © Juhani Välimäki 2003
Celsius and Fahrenheit
Solving Linear Inequalities Solving Linear Inequalities
START DEFINITIONS values (3) N1 = (8, 1,-9) i N1 average N3,2 sum N2 = 0 temp N1 Do not guess or assume any values! Follow the values of the variables.
Basics of Most C++ Programs // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose:
Temperature SOL 2.19 Grade 2 Created by; Kim Smith.
Two different ladders both go from the ground to the top of the same building. Ladder #1 has 100 rungs and ladder #2 has 120 rungs. Two people climb up.
1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems.
FINDING THE EQUATION OF A LINE 1.KNOWING A POINT AND THE SLOPE 2.KNOWING TWO POINTS.
Solving Inequalities Solving inequalities follows the same procedures as solving equations. There are a few special things to consider with.
Temp Conversions Centigrade, Fahrenheit, Absolute.
Topic: Heat and Temperature PSSA: C / S8.C.2.1.
TEMPERATURE Fahrenheit ( o F) Celsius ( o C) Kelvin (K)
Lecture 10 Flow of Control: Loops (Part 2) COMP1681 / SE15 Introduction to Programming.
DAY 2 – LINEAR REPRESENTATIONS Unit 1 – Linear Programming.
Solve a multi-step problem
Chapter 1 Algebra, Mathematical Models, and Problem Solving
Temperature conversions. C to F 1.Open excel 2. In cell "A1" type in "Celsius“ 3. In cell "B1" type in Fahrenheit 4. Since we are converting to celsius.
© 2017 SlidePlayer.com Inc. All rights reserved.