IF statements - selection Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
CFC Pledge Cards. Pledge Card Completing the Pledge Card Print all information using a black ballpoint pen. Please write firmly. If your Key Worker has.
Advertisements

CGI Programming Part 2. Input Tags Many different ways of getting data from the user. The tag is used most often. has a type attribute –Specifies the.
Group functions using SQL Additional information in speaker notes!
Limerick Checker Project Group Members: Jestin Ledlum Bryon Baumstarck Yining Wang.
PL/SQL - Using IF statements Please use speaker notes for additional information!
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
1 *Copyright © 2002 Pearson Education, Inc.. 2 Web Wizard’s Guide to CGI/Perl David Lash Chapter 3 Perl Basics.
Scalar Variables Start the file with: #! /usr/bin/perl –w No spaces or newlines before the the #! “#!” is sometimes called a “shebang”. It is a signal.
CSC3530 Software Technology Tutorial Two PERL Basics.
3ex.1 Note: use strict on the first line Because of a bug in the Perl Express debugger you have to put “use strict;” on the first line of your scripts.
DBM Databases Please use speaker notes for additional information!
Perl/cgi and an Access Database Please use speaker notes for additional information!
Understanding Your Paycheck and Tax Forms
Human Resources Features Human Resources Features (Cont.)
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
CGI and Perl - Basics Please use speaker notes for additional information!
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
Perl Web Page – Just Enough Pepper. Web site Set up the top of your script to indicate perl and plain text #!/usr/bin/perl print "Content-type:text/plain\n\n";
Problem Solving with the Sequential Logic Structure Lesson 5 McManusCOP10061.
Building PERL Scripts on a Windows system* *and running those scripts on an Apache server!
PAYROLL PROCESSING. PAYROLL In a company, payroll is the sum of all financial records of salaries, wages, bonuses, and deductions.
Data files using cgi/perl Please use speaker notes for additional information!
Mail with Perl/CGI Please use speaker notes for additional information!
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
Edit Programs Please use speaker notes for additional information. Example: payedit.cbl payedit.cbl.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
PROBLEM SOLVING WITH LOOPS Chapter 7. Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions.
SQL and Conditions Speaker notes will provide additional information!
Order Entry Program Please see speaker notes for additional information!
Functions Please use speaker notes for additional information!
Introduction to CGI/Perl Please use speaker notes for additional information!
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Chapter 4 Selection: the if-else and switch-case instructions.
Sending data, forms and variables Please use speaker notes for additional information!
AWW CALCULATIONS An explanation. 1. INSURER FILE NUMBER: 6. SOCIAL SECURITY NUMBER 7. WCB FILE NUMBER: 2. EMPLOYER NAME: Store 8. EMPLOYEE LAST NAME:
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
PSD/CSD PSD/CSD is a snapshot of district employee’s salary information on September 15 th Certified Rank Salary Tables, PSD and CSD files due to KDE by.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Lesson 5 McManus COP  Algorithm Instructions  Sequential Logic Structure  Solution Development McManusCOP10062.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
PHP with MYSQL Please use speaker notes for additional information!
Optimizing your GDT Environment. Optimizing Your GDT Environment Doug Evans GDT 2004 International User Conference – Evolving the Legacy July
Sequential Processing to Update a File Please use speaker notes for additional information!
File Handle and conditional Lecture 2. File Handling The Files associated with Perl are often text files: e.g. text1.txt Files need to be “opened for.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
CSE202: Lecture 5The Ohio State University1 Selection Structures.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
More SQL functions As usual,there is additional information in the speaker notes!
 Prepared by: Eng. Maryam Adel Abdel-Hady
Java Project 3 In Class Practice. IF Statements Create a simple program that allows the user to enter a test score as an integer. If the test score is.
Sending data with CGI/Perl Please use speaker notes for additional information!
CS 330 Class 10 Programming plan for today: More files Saving data from a form.
Variable scope. Variable Scope Variables do not live forever. Failing to take that into account leads to problems. Let's look at an example. Let's write.
Chapter 7 - Introduction to Common Gateway Interface (CGI)
Unix Scripts and PBS on BioU
CS120 The Information Era TOPICS: CGI-Scripts 4/18/05
BUSI-3400 Tutorial #1 Sept 24, 2012 Tim Smith.
SUMMER SESSION PAYMENT EXPLANATION
Handling Exceptions.
The Selection Structure
Perl Web Page – Just Enough
In Class Exercises Phil Tayco Slide version 1.1 San Jose City College
2 file sequential matching with multiple records allowed on file 2
Print or display a list of all records where the state is equal to either MA or RI. EndLOOP problems. The loop is the only thing that will be different.
Problem #2: Print or display a list of all records where the year of birth is greater than 1980 and the marital status is married.
Problem #2: Print or display a list of all records where the year of birth is greater than 1980 and the marital status is married.
Print or display a list of all records where the state is equal to either MA or RI.
Print a list of all people in department 15 who either are salaried and make more than or are part time or full time and make more than 25 per hour.
Iteration – While Loops
Presentation transcript:

IF statements - selection Please use speaker notes for additional information!

Record shown being processed on previous slide. The divider is,space.

Mailing List Mailing List Enter Name: Enter Address: Enter City: Enter State: Enter ZIP: Enter Job Type (S for Salaried, F for Full Time Hourly, P for Part Time Hourly): Enter Job Code: Enter Pay Per Hour: or Enter Salary:

#!/usr/bin/perl #payroll.cgi - saves name and address information to make a mailing list use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); #assign variables $name = param('name'); $stadr = param('stadr'); $city = param('city'); $state = param('state'); $zip = param('zip'); $jobtype = param('jobtype'); $jobcode = param('jobcode'); $payperhr = param('payperhr'); $salary = param('salary'); #save form data to a file open(FILEOUT, ">>", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print FILEOUT "$name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary\n"; close(FILEOUT); print " Record just entered \n"; print " \n"; print "$name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary\n"; print " \n"; Code to write records to sequential file.

#!/usr/bin/perl #payrollrd.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/,/,$_); print "$name \n"; } close(INF); print " \n"; The while loop in this case is set up to handle all the records in the file. This is coded with while( ) where INF is the name I used to open and close the file. The code in the while loop is enclosed with curly brackets.

#!/usr/bin/perl #payrollsal.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print " Salaried Workers \n"; print " \n"; print " Salaried Workers: \n"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_); if ($jobtype eq "S") { print "$name - Salaried - $jobtype \n"; } close(INF); print " \n"; Note that the split divider is given as,space.

#!/usr/bin/perl #payrollsal1.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print " Salaried Workers \n"; print " \n"; print " Salaried Workers: \n"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_); if ($jobtype eq "S") { print "$name - Salaried - $jobtype \n"; } else { print "$name - Hourly - $jobtype \n"; } } close(INF); print " \n";

#!/usr/bin/perl #payrolljobcd.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print " Salaried Workers \n"; print " \n"; print " Salaried Workers: \n"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_); if ($jobcode == 1 ) { print "$name - Job Type #1 - $jobcode \n"; } else { print "$name - All Other Job Types - $jobcode \n"; } } close(INF); print " \n";

if ($jobcode == 1 ) { print "$name - Job Type #1 - $jobcode \n"; } else { print "$name - All Other Job Types - $jobcode \n"; }

#!/usr/bin/perl #payrollsalamt.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print " Employees \n"; print " \n"; print " Employees: \n"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_); if ($jobtype eq "S") { if ($salary >= 50000) { print "$name - $salary - Salary greater than \n"; } else { print "$name - $salary - Salary not greater than or equal to \n"; } else { print "$name - $payperhr - Hourly employee \n"; } close(INF); print " \n";

jobtype eq “S” salary >= Salary > Salary not > Hourly employee Y Y N N if ($jobtype eq "S") { if ($salary >= 50000) { print "$name - $salary - Salary greater than \n"; } else { print "$name - $salary - Salary not greater than or equal to \n"; } else { print "$name - $payperhr - Hourly employee \n"; }

#!/usr/bin/perl #payrollcom.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print " Employees \n"; print " \n"; print " Employees: \n"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_); if ($jobtype eq "S" and $salary >= 50000) { print "$name - $salary - Salary greater than \n"; } else { print "$name - other employees \n"; } close(INF); print " \n";

if ($jobtype eq "S" and $salary >= 50000) { print "$name - $salary - Salary greater than \n"; } else { print "$name - other employees \n"; } jobtype eq “S” salary >= Salary > Other employee Other employee Y Y N N

#!/usr/bin/perl #payrollcomor.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print " Employees \n"; print " \n"; print " Employees: \n"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_); if ($jobtype eq "S") { print "$name - $jobtype - $jobcode - jobtype = S \n"; } else { if ($jobcode == 1) { print "$name - $jobtype - $jobcode - jobcode = 1 \n"; } else { print "$name - other employees \n"; } close(INF); print " \n";

if ($jobtype eq "S") { print "$name - $jobtype - $jobcode - jobtype = S \n"; } else { if ($jobcode == 1) { print "$name - $jobtype - $jobcode - jobcode = 1 \n"; } else { print "$name - other employees \n"; } jobtype eq “S” jobcode= 1 Other employee Y Y N N jobtype=S

#!/usr/bin/perl #payrollcomor.cgi - reads the payroll file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary); open(INF, "<", "payroll.txt") or die "file error: payroll.txt. $!, stopped"; print " Employees \n"; print " \n"; print " Employees: \n"; while( ) { chomp($_); ($name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_); if ($jobtype eq "S" or $jobcode == 1) { print "$name - $jobtype - $jobcode - either S or 1 \n"; } else { print "$name - other employees \n"; } close(INF); print " \n";

if ($jobtype eq "S" or $jobcode == 1) { print "$name - $jobtype - $jobcode - either S or 1 \n"; } else { print "$name - other employees \n"; } jobtype eq “S” jobcode= 1 Either S or 1 Other employee Y Y N N Either S or 1