Lecture-06.2.2

Lecture-06.2.2 - program Lab6 implicit none character*9...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 1540.03 Week 6.2.2 February 8, 2012 Design of Programs Read Chapter 9 of the textbook. Appreciate the step-by-step process of breaking down a problem and how an algorithm can be made better. Pay particular attention to the sections on program specifications, defensive programming, program correctness and programming style. Example: Lab 6 The problem neatly breaks into several pieces: - the loop that requests processing a date - input a month and convert it to a number - input the day and check for valid date 1. the loop that requests processing a date program Lab6 implicit none character*1 reply do print*, "Do you want to convert a date, Y or N?" read*, reply if (reply .eq. "N" .or. reply .eq. "n") exit print*, "process a date" end do stop end 2. input a month and convert it to a number
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: program Lab6 implicit none character*9 month integer monthNum, pos character*108 months months = "January February March April & &May June July August & &SeptemberOctober November December " print*, "Enter the month name" read*, month pos = index(months,month) if (pos .eq. 0) then print*, "The month is invalid" else monthNum = pos/9 + 1 ! process day print*, month, " is month #", monthNum print*, "now process day" end if stop end 3. input the day and check for valid date if ( February ) then if ( valid day ) then output date else error message end if else if ( April, June, September or November ) then if ( valid day ) then etc. CSE 1540 Week 6.2.2 February 8, 2012 page 1 of 1...
View Full Document

This note was uploaded on 02/13/2012 for the course CSE 1540 taught by Professor Hofbauer during the Winter '12 term at York University.

Ask a homework question - tutors are online