You are on page 1of 7

1.

Write a Visual Basic application that converts a Celsius temperature to its Fahrenheit
equivalent. The Iormula is:

Make the Celsius temperature a named constant so that its value can be changed
easily. The program should print both the value oI the Celsius temperature and its
Fahrenheit equivalent, with appropriate identiIying messages. Display the output in a
single label. Be sure to include appropriate comments in your program, choose
meaningIul identiIiers, and use indentation as we do in the programs in this chapter.
1. Write a Visual Basic application that calculates and prints the diameter, the
circumIerence, or the area oI a circle, given the radius. The application should have
three buttons, one Ior diameter, one Ior circumIerence, and one Ior area. The user
should be prompted to enter the radius in Iloating-point Iorm and press the
appropriate button. The output should be labeled appropriately. For example, iI the
input is 6.75 and the area button is pressed, your program should print something like
this:
The area of a circle with radius 6.75 is 143.14
ere are the Iormulas you need:
2
2
2
Diameter r
Circumference r
r
6
6


where r is the radius. Use 3.14159265 Ior a.
ueslgn and code a vlsual 8aslc appllcaLlon Lo read an lnvolce number quanLlLy ordered and unlL
prlce (all lnLegers) and compuLe Lhe LoLal prlce 1he appllcaLlon should wrlLe ouL Lhe lnvolce number
quanLlLy unlL prlce and LoLal prlce on Lhe screen wlLh ldenLlfylng phrases lormaL your program
wlLh conslsLenL lndenLaLlon use approprlaLe commenLs and meanlngful ldenLlflers 1he daLa ls
prompLed for and read from Lhe screen use buLLons where approprlaLe

1. ou have bought a car, taking out a loan with an annual interest rate oI 9. ou
expect to make 36 monthly payments oI $165.25 each. ou want to keep track oI the
remaining balance you owe aIter each monthly payment. The Iormula Ior the
remaining balance is:
1 (1 )
n

i
Bal pmt
i




where
o Bal

balance remaining aIter the th payment


o payment number (1, 2, 3, .)
o pmt amount oI the monthly payment
o i interest rate per month (annual rate 12)
o n total number oI payments to be made
Write an application to calculate and display the balance remaining aIter the Iirst, second, and
third monthly car payments. BeIore showing these three results, the program should output
the values on which the calculations are based (monthly payment, interest rate, and total
number oI payments). Display an identiIying message with each numerical result. Be sure to
include appropriate comments in your program, choose meaningIul identiIiers, and use
indentation as we do in the programs in this chapter.
1. Design and write a Visual Basic application that inputs a single letter and prints out
the corresponding digit on the telephone. The letters and digits on a telephone are
grouped this way:
2 ABC 4 G 6 MNO 8 TUV
3 DEF 5 JKL 7 PRS 9 WX
2. No digit corresponds to either Q or Z. For these two letters, your application should
print a message indicating that they are not used on a telephone.
3. The application should have two buttons, one to enter input and one to quit. The
screen dialog might look like this:
4. Enter a single letter, and I will tell you what the corresponding
5. digit is on the telephone.
6.
7. R
8.
9. The digit 7 corresponds to the letter R on the telephone.
10.ere's another example:
11. Enter a single letter, and I will tell you what the corresponding
12. digit is on the telephone.
13.
14. Q
15.
16. There is no digit on the telephone that corresponds to Q.
17.our program should print a message indicating that there is no matching digit Ior
any nonalphabetic character the user enters. Also, the program should recognize only
uppercase letters. nclude the lowercase letters with the invalid characters. Prompt the
user with an inIormative message Ior the input value, as shown above.
18.Use proper indentation, appropriate comments, and meaningIul identiIiers throughout
the program





1he llrsL naLlonal 8ank of arkland has asked you Lo deslgn and develop an accounL LransacLlon
daLabase sysLem 1he sysLem allows bank employees Lo

1) SeLup an accounL for a new cusLomer (make sure your sysLem can hold aL leasL 20 LoLal
cusLomers) Lvery cusLomer accounL should conLaln Lhe cusLomer flrsL and lasL name address soclal
securlLy number (SS#) lnLeresL raLe and a fleld for Lhe LoLal balance ln Lhe accounL

2) rlnL accounL lnformaLlon for a slngle cusLomer or Lhe enLlre llsL of cusLomer accounLs lnclude ln
Lhe ouLpuL all lnformaLlon for each accounL (name address SS# lnLeresL raLe Lype of accounL
balance) ln a readable and well organlzed ouLpuL formaL


uevelop a menudrlven lnLeracLlve sysLem LhaL provldes bank employees wlLh a menu llsLlng Lhe
varlous commands avallable and conLlnue unLll Lhe user LermlnaLes Lhe program An example of a
Lyplcal sesslon mlghL look llke


Welcome Lo Lhe llrsL naLlonal 8ank
of arkland AccounL LransacLlon sysLem


LnLer any of Lhe followlng commands
1) CreaLe accounL
2) rlnL accounLs
3) SelecL accounL
4) ueposlL
3) WlLhdrawal
6) CulL
12, Lowest Score Drop
This program is to calculate the average oI a series oI test scores where the lowest score in
the series is dropped. t should use the Iollowing Iunctions :
* gofVnIuos should ask Ior Iive test scores and store them in variables.
* fInd!owosf should determine which oI the Iive score is the lowest, and return that value.
* cnIcAvorngo should calculate and display the average oI the Iour highest scores.
nput Jalidation. Do not accept test scores higher than 100 or lower than 0.
$& 1hls program wlll calculaLe Lhe average of a serles of LesL scores where Lhe
lowesL score
ln Lhe serles ls dropped lnpuL ls from Lhe user responses aL keyborardand ouL
puL wlll
be calculaLed and dlsplayed varlables used &$

10, Payroll Report
Write a program that displays a weekly payroll report. A loop in the program should ask the
user Ior the employee number, gross pay, state tax, Iederal tax, and FCA withholdings. The
loop will terminate when 0 is entered Ior the employee number. AIter the data is emtered, the
program should display totals Ior gross pay, state tax, Iederal tax, FCA withholdings, and net
pay.
nput Jalication. Do not accept negative number for any of the items entered. Do not accept
values for state, federal, or FCA withholdings that are greater than the gross pay. f the
state tax federal tax FCA withholdings for any employee are greater than gross pay,
print an error message and as the user to re-enter the data for that employee.
6, SoItware Sales
A software company sells a package that retails for $99. Quantity
discounts
are given according to the following table.

Quantity Discount
-------- --------
10-19 20%
20-49 30%
50-99 40%
100 or more 50%

Write a program that asks for the number of units sold and computes the
total
cost of the purchase.

Input Validation: Make sure the number of units is greater than 0.

ueslgn and code a vlsual 8aslc appllcaLlon Lo read an lnvolce number quanLlLy ordered and unlL
prlce (all lnLegers) and compuLe Lhe LoLal prlce 1he appllcaLlon should wrlLe ouL Lhe lnvolce number
quanLlLy unlL prlce and LoLal prlce on Lhe screen wlLh ldenLlfylng phrases lormaL your program
wlLh conslsLenL lndenLaLlon use approprlaLe commenLs and meanlngful ldenLlflers 1he daLa ls
prompLed for and read from Lhe screen use buLLons where approprlaLe
$& 1hls program wlll ask Lhe number of unlLs sold and compuLe Lhe LoLal cosL of
Lhe purchase
lnpuL ls from Lhe user responses aL keyborard and ouL puL wlll be calculaLed and
dlsplayed
varlables used quanLlLy cosL &$

#lncludelosLreamh
#lncludelomanlph $$ for seLw

vold maln (vold)

lnL quanLlLy
double cosL

couL Pow many unlLs sold ? endl
couL LnLer Lhe quanLlLy
cln quanLlLy

lf ( quanLlLy 10 quanLlLy 19) $$ lf else $ lf sLaLemenL
cosL 99 & quanLlLy & 08 $$ calculaLeLlon
couL 1oLal cosL ls seLw(23) cosL endl endl $$ seLw

else lf ( quanLlLy 20 quanLlLy 49)

cosL 99 & quanLlLy & 07
couL 1oLal cosL ls seLw(23) cosL endl endl

else lf ( quanLlLy 30 quanLlLy 99)

cosL 99 & quanLlLy & 06
couL 1oLal cosL ls seLw(23) cosL endl endl

else lf ( quanLlLy 100 )

cosL 99 & quanLlLy & 06
couL 1oLal cosL ls seLw(23) cosL endl endl

else
couL LnLer Lhe number over 10 endl endl



Write a program that converts centigrade temperate to Fahrenheit
temperature.
The formuls is
F = (9/5) C + 32
F is the Fahrenheit temperature and C is the centigrade temperature.


A retail company must file a monthly sales tax report listing the sales
for the
month and the amount of sales tax collected. Write a program that asks
for the
month, the year, and the total amount collected at the cash register
(that is,
sales plus sales tax). Assume the state sales tax is 4% and the country
sales
tax is 2%.
If the total amount collected is known and the total sales tax is 6%, the
amount
of product sales may be calculated as:
S = T/1.06
S is the product sales and T is the total income (product sales plus
sales tax).
The program should display a report similar to
Month: Jctober
-------------------
Total Collected: $ 26572.89
Sales: $ 25068.76
Counrty Sales Tax: $ 501.38
State Sales Tax: $ 1002.75
Total Sales Tax: $ 1504.13

Program Name: Stadium Seating

There are three seating categories at a stadium. For a softball game,
Class A
seats cost $15, Class B cost $12, and Class C seats cost $9. Write a
program
that asks how many tickets for each class of seats were sold, then
display the
amount of income generated from ticket sales. Format your dollar amount
in
fixed-point notation, with two decimal places of precision, and be sure
the
decimal point is always displayed.


Write a program that asks the user to enter an item's wholesale cost and
its
markup percentage. It should then display the item's retail price. For
example:
If an item's wholesale cost is 5.00 and its markup percentage is 100%,
then the item's retail price is 10.00.
If an item's wholesale cost is 5.00 and its markup percentage is 50%,
then
the item's retail price is 7.50.
The program should have a function named calculateRetail that receives
the
wholesale cost and the markup percentage as arguments, and returns the
retail
price of the item.
Input Validation: Do not accept negative values for either the wholesale
cost
of the item or the percent markup.

The formula for converting a temperature from Fahrenheit to Celsius is

C = 5/9 ( F - 32)

where F is the Fahrenheit temperature and C is the Celsius temperature.
Write
a function named celsius that accepts a Fahrenheit temperature as an
argument.
The function should return the temperature, converted to Celsius.
Demonstrate
the function by calling it in a loop that displays a table of the
Fahrenheit
temperatures 0 through 20 and their Celsius equivalents.

A care with 20 gallon gas tank averages 21.5 miles per gallon when driven
in
town and 26.8 miles per gallon when driven on the highway. Write a
program that
calculates and display the distance the car can travel on one tank of gas
when
driven in town and when driven on the highway.

You might also like