1 / 12

ENEE150 Recitation 7

ENEE150 Recitation 7. Outline. Project 2 Structures. Announcements. Project 1 grades should be coming out this weekend. Project 2: ENEE Airplanes Flight Database. Parse input files, print menu, prompt user Three input files – use file I/O Airports.txt Routes.txt Flights.txt

ananda
Download Presentation

ENEE150 Recitation 7

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

E N D

Presentation Transcript


  1. ENEE150 Recitation 7

  2. Outline • Project 2 • Structures

  3. Announcements • Project 1 grades should be coming out this weekend

  4. Project 2: ENEE Airplanes Flight Database • Parse input files, print menu, prompt user • Three input files – use file I/O • Airports.txt • Routes.txt • Flights.txt • intargc, char *argv[] • If files cannot be opened, print error message

  5. Menu • Print for user input • User must enter a number: 1 – 4 • If the number is not 1 – 4, print error message

  6. Airports.txt • Contains 3-letter airport code and location • Format • 3-letter airport code • Two whitespaces • Airport location • ‘\n’ character at end of line • Example: BQN Aquadilla, Puerto Rico • Notice there are spaces within the string • May want to use ‘\n’ to recognize end of string

  7. Routes.txt • Shows the non-stop flights • Format • Unique route ID (integer) • ‘.’ character • Two whitespaces • Departure airport code • Whitespace • Arrival airport code • Alphabetical order (by city) of the departure and then alphabetical order of arrival

  8. Flights.txt • Format • Unique flight number (integer) • Route ID/number • Departure time • 12 hour format • ‘a’ for am and ‘p’ for pm • Arrival time • Repeat • ‘Daily’ • Numbers • Numbers are the days that the flight runs • ie. 23 which would represent Monday and Tuesday • Xnumber • Numbers after ‘X’ represent days that the flight doesn’t run • ie. X7 which is NOT Saturday

  9. Menu Options • Option 1 – Print flights • Enter flight number • If flight doesn’t exist, print error message • Option 2 – Print airports • Enter 3-letter airport code • If flight doesn’t exist, print error message • Option 3 – Nonstop flights • Prompt for two airport codes • Prompt for days (0 means any day) • Option 4 – 1-stop flights • Same prompt and error conditions as option 3

  10. Important Notes • There will never be more than • 100 airports in airports.txt • 500 routes in routes.txt • 3000 flights in flights.txt • 2000 characters per line • 100 characters per string • String.h is allowed (strcmp?) • fgets • Structures are allowed

  11. Checking Your Project • Get output files from website • Transfer them to GLUE • Generate your output • a.out< test1.in > ! output.txt • diff test1.out output.txt • Newline characters at the end of the file are ok

  12. Structures • Group different types together • Usually use typedef • Pass by value (as oppose to pass by reference) • struct.c

More Related