Date: Mon, 11 Nov 1996 17:21:46 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Mon, 04 Nov 1996 18:14:56 GMT Content-length: 5768 CS110 Program 0

Program 0

Program 0 is designed to give you practice editing, compiling, and executing a program. Before doing this assignment you may want to read our web page on Microsoft Windows. You are also advised to go through the introductory tutorial of Borland C++

Enter the following C++ program as it appears below, between the lines of asterisks. It will run as written, so you need not modify the program.

Please remember to put your name, login ID (not your password!) and your course section number in the program documentation (comments at the top of the program).

If you want to save yourself some typing, you can click here and then go to the "File" menu on Netscape and do a "Save as...". This will let you save the program listed below without having to type it in. You will still need edit the file to put in your name, etc.

The Program:

*******************************************************************************

/*
Name: [your name here]
Login: [your login ID here]
Section: [your class section number here]

This program computes the gross wages, income taxes, and net wages for
an employee when given the pay rate and number of hours worked.

*/

#include <iostream.h>	// This file must be included to do input & output.

main()
{
	int hours;		// number of hours worked in the week
	float payRate;		// rate of pay in dollars per hour
	float taxRate;		// income tax rate
	float netWages;		// net pay for the week (pre-tax)
	float taxes;		// amount paid in income tax
	float grossWages;	// gross pay for the week (post-tax)

	taxRate = .175;		// set the tax rate to 17.5%

	cout << "Enter the number of hours worked: ";
	cin >> hours;

	cout << "Enter the hourly rate of pay: $";
	cin >> payRate;

	// compute the taxes and gross and net wages
	netWages = hours * payRate;
	taxes = netWages * taxRate;
	grossWages = netWages - taxes;

	// print out the net wages, taxes, and gross wages
	cout << "Net wages: " << netWages << "\n";
	cout << "Taxes: " << taxes << "\n";
	cout << "Gross wages: " << grossWages << "\n";
}
*******************************************************************************

Borland C++ 4.5 Hints

Log into your account, and start Borland C++ 4.5 which is found in the CSApps program group. Make sure you are using 4.5 instead of 4.0 -- your CSApps program group may contain both. When you have Borland up and running, you want to first create a file to write your program in. You click on File in the left corner of the screen, and choose New within the menu that drops down. An empty box will appear on your screen; this is where you will write your program. You will want to save your programs often. The first time you save it, choose Save as within the File menu. This will ask you to name the file. Remember, since this will be a program file, the name must end with .cpp. The second time you save, you can just choose Save, and it will be done automatically. To access a file that you have previously saved to the disk, simply choose Open from the File menu and then let the computer know what file you wish to access.

Once you have the program typed into the file window, and you have saved the program in case something unsavory happens, then you just need to press the little lightening bolt button near the top of the screen. Your program will be compiled, linked, and run. If you mis-typed something, chances are you will get a syntax error. Go back to the program, check your typing, and when the mistake is found, change it and run the program again.

When the program runs, it will create a window, and prompt you to enter a number of hours worked and an hourly rate of pay. It will then compute the taxes and net and gross salaries using these numbers. You know that the program has run to completion by the appearance of the word INACTIVE at the top of the window.

Turning in the assignment

When you turn in programs, I am going to want you to bring a printed copy of the program to me at the beginning of class on the day it is due. I am also going to want an electronic copy dropped into a secure area of the disk (see below for details).

To print a copy of the program, go back to the File menu, and choose Print. Click on OK in the little window that appears. The pages will automatically be printed in the printer room across the hall (room 1359). You can determine which printer will do the printing by checking out the Check Print Queues icon in the Administration folder. (It may take a few seconds to show your name).

To hand in an electronic copy of the program, you must use the File Manager program in the Main group. However, this time you will be dropping the program from your directory into a handin directory. You can locate the correct handin directory for you by first going to the r drive, opening the handin folder, finding another folder marked hummert and opening that, and then locating the final folder that contains your login name. You are to drop your program0.cpp file into the folder with your name.

Even though this program is not graded, it is important that you turn the electronic as well as a printed copy of the assignment in to me correctly (so I can make sure there are no problems).