01042006vb
PG 45 building a payroll program-1st version
Where does the C derived from? What does it stand for?
c replaces pascal as a teaching language. Pg 11
Language called B, B came from BCPL which came from CPL which came from Algon
on page 45:
2a: Computing the Gross Pay without tax
message box 2a = "GROSSPAY IS" &grosspay
2b. Net pay= gross less tax
message box 2b = "GROSSPAY IS" &grosspay
message box 2b "TAX AMOUNT IS" &taxamount
message box 2b = "NETPAY IS" &netpay
Variable name NOSPACE
Outside of the quotation variable can't have space between words
Leave 10 spaces after the word "is" for formatting reasons
In payroll program we will be suing name
e.g hourlyrate, grosspay, netpay, taxamount etc
Convention of naming use lowercase without using any special characters
Case study on page 51
employeeid, hoursworked, hourlyrate, grosspay, taxamount,netpay
The above variables are input variables, case study requires these will be the output.
what goes in comes out correctly
2A:
MSG BOX "EMPLOYEE ID "&employeeid
MSG BOX = "HOURS WORKED "&hoursworked
MSG BOX "HOURLY RATE "&hourlyrate
MSG BOX "GROSS PAY "&grosspay
2b
MSG BOX "EMPLOYEE ID "&employeeid
MSG BOX = "HOURS WORKED "&hoursworked
MSG BOX "HOURLY RATE "&hourlyrate
MSG BOX "GROSS PAY "grosspay
MSG BOX "TAX AMOUNT "&taxamount
MSG BOX "NET PAY "&netpay
ORDER IS VERY IMPORTANT, therefore GROSSPAY has to be before NETPAY
Tax amount has to be before net pay.
What operation is needed for 2a? Multiplication Line 14, pg 45
grosspay=hoursworked*hourlyrate
Operation needed for 2B is subtraction
grosspay=hoursworked*hourlyrate
taxamount=grosspay*taxrate
netpay=grosspay-taxamount
To input data into program we are going to use inputbox
what is syntax of inputbox
inputbox : employeeid=inputbox "EMPLOYEE ID"
THIS INPUTBOX HAS TO BE ASSIGNED TO A VARIABLE NAME=EMPLOYEE ID
1ST stage of programming is to type it.
syntax error says declaration is missing
HOW DO U DECLARE A VARIABLE NAME
START WITH A HISTORICAL WORD DIM FOLLOWED BY NAME ITSELF, FOLLOW BY THE WORD AS, FOLLOWED BY THE TYPE OF DATA (integer, single, char, double, string, etc...)
Where does the Java come from? Ans: Coffee bean, from an
Island in Indonesia.
Java was known as OAK
Unix Operating System: It's opponent of Microsoft Operating system.
On page 45:
2A) Computing the Gross Pay without Tax
msgbox ("GROSSPAY IS "&grosspay)
2B) Net pay with Tax
msgbox ("GROSSPAY IS "&grosspay)
msgbox ("NETPAY IS "&netpay)
Netpay has TAXAMOUNT included. (Do not leave space)
Leave 10 spaces after the word "IS" for formatting reasons
In Payroll program we will be using name
Convention of naming is that to use all lowercase without using any special
characters.
employeeid
hoursworked
hourlyrate
the above variables are input variables, case study requires these will be the output.
problem specification
what goes in comes out. Always you need to test your input data.
Therefore,
msgbox("EMPLOYEE ID "&employeeid)
msgbox("HOURS WORKED "&hoursworked)
msgbox("HOURLY RATE "&hourlyrate)
msgbox("GROSS PAY "&grosspay)
msgbox("TAX AMOUNT "&taxamount)
msgbox("NET PAY "&netpay)
ORDER IS VERY IMPORTANT, therefore GROSS PAY has to be before NETPAY
tax amount has to be before net pay
What is Operation? Multiplication,
line 14 page 45,
grosspay=hoursworked*hourlyrate
syntax error if you put X instead of * (look at page 17; mysteries of programming)
Computation for 2B
grosspay=hoursworked*hourlyrate
taxmount=grosspay*taxrate
netpay=grosspay-taxamount
to input data into program we are going to use inputbox
what is syntax of inputbox
inputbox("ENTER THE EMPLOYEE ID")
This inputbox has to be assigned to a variable name
what is the variable name that above inputbox will be assigned?
employeeid=inputbox("EMPLOYEE ID")
Programming is not about math, its not about art, its not about science, its not about engineering, its not about sociology. Programming is all of the above. You need science to prove what you are doing and art to make it beautiful.
Now we are going to have hands on experience which is explained in the handout.
How would we write a program using VB .Net?
case study on page 51.
Make sure to be consistent in naming. What's wrong with these two words?
hoursworked and hourworked.
one has "S" other doesn't.
Variable name NO SPACE
Outside of the quotation variable can't have space between the words.
click on new project
when you see this , please smile.
double click on the form box.
The first stage of the program is to type but don't type fast.
There is a problem with this program. What is it?
we are building the solution. Click on build and hit build solution.
SYNTAX ERROR SAYS DECLARATION IS MISSING.
HOW DO YOU DECLARE A VARIABLE NAME.
START WITH A HISTORICAL WORD DIM, FOLLOWED BY NAME ITSELF, FOLLOW BY THE WORD AS, FOLLOWED BY THE TYPE OF DATA (integer,single,char,double,string, etc...)
dim employeeid as integer
integer is whole is number
single is fraction
double is fraction either is too small or too big, double room occupancy
char is one letter or one digit or one hit
string is more than one
here is the whole program
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim employeeid As Integer Dim hoursworked As Integer Dim hourlyrate As Single Dim taxrate As Single Dim taxamount As Integer Dim grosspay As Single Dim netpay As Single 'start of input data'
InputBox("ENTER THE EMPLOYEE ID")
employeeid = InputBox("EMPLOYEE ID")
hoursworked = InputBox("HOURS WORKED")
hourlyrate = InputBox("HOURLY RATE")
taxrate = InputBox("TAX RATE")
'start of process or computation'grosspay = hoursworked * hourlyrate
taxamount = grosspay * taxrate
netpay = grosspay - taxamount
MsgBox("EMPLOYEE ID " & employeeid)
MsgBox("HOURS WORKED " & hoursworked)
MsgBox("HOURLY RATE " & hourlyrate)
'start of output'MsgBox("GROSS PAY " & grosspay)
MsgBox("TAX AMOUNT " & taxamount)
MsgBox("NET PAY " & netpay)
End Sub
End
Class
There is a logical error there, there is an extra spurious (extraneous line)
Final program for this payroll
Dim employeeid As Integer Dim hoursworked As Integer Dim hourlyrate As Single Dim taxrate As Single Dim taxamount As Integer Dim grosspay As Single Dim netpay As Single 'start of input data'
employeeid = InputBox("ENTER THE EMPLOYEE ID")
hoursworked = InputBox("HOURS WORKED")
hourlyrate = InputBox("HOURLY RATE")
taxrate = InputBox("TAX RATE")
'start of process or computation'grosspay = hoursworked * hourlyrate
taxamount = grosspay * taxrate
netpay = grosspay - taxamount
MsgBox("EMPLOYEE ID " & employeeid)
MsgBox("HOURS WORKED " & hoursworked)
MsgBox("HOURLY RATE " & hourlyrate)
'start of output'MsgBox("GROSS PAY " & grosspay)
MsgBox("TAX AMOUNT " & taxamount)
MsgBox("NET PAY " & netpay)