Chapter 3 Programming Projects


[Page 128 (continued)]

  1. Write a program that allows the user to specify two numbers and then adds, subtracts, or multiplies them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result.

  2. Suppose automobile repair customers are billed at the rate of $35 per hour for labor. Also, costs for parts and supplies are subject to a 5% sales tax. Write a program to display a simplified bill. The customer's name, the number of hours of labor, and the cost of parts and supplies should be entered into the program via text boxes. When a button is clicked, the customer's name (indented) and the three costs should be displayed in a list box, as shown in the sample run in Figure 3.30.

    Figure 3.30. Sample run for Programming Project 2.


  3. [Page 129]
  4. At the end of each month, a credit card company constructs the table in Figure 3.31 to summarize the status of the accounts. Write a program to produce this table. The first four pieces of information for each account should be read from a text file. The program should compute the finance charges (1.5% of the unpaid past due amount) and the current amount due.

    Figure 3.31. Status of credit card accounts.

  5. Table 3.8 gives the projected 2005 distribution of the U.S. population (in thousands) by age group and sex. Write a program to produce the table shown in Figure 3.32. For each age group, the column labeled "%Males" gives the percentage of the people in that age group who are male, and the column labeled "%Females" gives this information about the female population. The last column gives the percentage of the total population in each age group. Note: Store the information in Table 3.8 in a text file. For instance, the first three lines in the file should contain the following data: Under 25, 51210, 48905. Read and add up the data once to obtain the total population, and then read the data again to produce the table.

    Table 3.8. Projected U.S.population (2005).

    Age Group

    Males

    Females

    Under 25

    51,210

    48,905

    2564

    74,169

    77,059

    65+

    15,319

    21,051


    Figure 3.32. Output of Programming Project 4.


  6. [Page 130]
  7. Write a program to convert a U.S. Customary System length in miles, yards, feet, and inches to a Metric System length in kilometers, meters, and centimeters. A sample run is shown in Figure 3.33. After the numbers of miles, yards, feet, and inches are read from the text boxes, the length should be converted entirely to inches and then divided by 39.37 to obtain the value in meters. The Int function should be used to break the total number of meters into a whole number of kilometers and meters. The number of centimeters should be displayed to one decimal place. Some of the needed formulas are as follows:

    Figure 3.33. Sample run for Programming Project 5.

    total inches = 63360 * miles + 36 * yards + 12 * feet + inches

    total meters = total inches/39.37

    kilometers = Int(meters/1000)




An Introduction to Programming Using Visual Basic 2005
Introduction to Programming Using Visual Basic 2005, An (6th Edition)
ISBN: 0130306541
EAN: 2147483647
Year: 2006
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net