The captain is Matthew. We are going to concentrate on the file, discussing assignment 3A and 3B. These assignments are related to the last question on the test. It was the search program. Do you know if google is a search program? Can you make the interface?

You have image, label, title, hyper label, text box, buttons. Buttons are programs. As extra credit, try to redesign the interface.

Try to mimic the google.

Talked about the story of Bill Gates and the story of how BASIC started.

We discussed the importance of the programming, what search engine is, and Y2K.

3B) Expand Payroll Program so that repeats for 5 employees from an input file.

Data typed and saved under employee in

#include <fstream.h>instead of <iostream.h>

Use ifstream fin( "employee.in");

Use the same while loop as 3A

What is the significance of the assignment 3B?

You get the information from the file.

What is the name of the data file?

 ( " employee.in " )

What is inside that file?

Your employee ID, hours worked, hourly rate, marital status, name, social security, address, telephone number.

Your data file is at this moment only employee ID, hours worked, hourly rate, marital status, and name.

We have to use a variable name for the file.

What is the name that we're going to use for the data file?

The name used in the program is fin.

For example, fin.readline.

How would you assigning it to hours worked?

hw = fin.readline

3D works with end of file.

The difference between 3B and 3D is that 3B loops as many times as possible.

Q5a) Run the following program. Briefly say in your own words what does it do?

 

Create a new project and use your name in the project title, save it on your F: drive (your account). Create a text file called employees.txt and save it desktop or in the “bin” folder of your project. Enter data into your text file including the name and gross pay of employees in the following format:

Andres

1000.00

John

500.00

Lina

750.00

Peter

456.00

Anna

670.00

 

 

 

 

 

 

 

 

Create a form similar to:

 

 

 

Double-click on the button to write the code:

 

  Dim name As String

        Dim grosspay As Double

        Dim i As Integer

 

        Dim fin As IO.StreamReader = IO.File.OpenText("employees.txt")

 

        For i = 1 To 5

 

            name = fin.ReadLine

            grosspay = fin.ReadLine

 

            If name = TextBox1.Text Then

                TextBox2.Text = FormatCurrency(grosspay)

            End If

 

        Next

 

5b)Explain what this program does and how it works (e.g. what does the loop do, what does the If … Then statement do)

 

 

How to create a text file and write to a file  

dim fout as Io.streamWriter = Io.File.CreateText("employee2.txt)

fout.writeline(textbox1.text)

fout.writeline(textbox2.text)

fout.close

We discussed in detail, how a file works with a program and how to convert an above program to assignment 3B and assignment 3D.