19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3. Rudimentary Translator. Table 6.10 gives English words <strong>and</strong> their French <strong>and</strong><br />

German equivalents. Store these words in a data file <strong>and</strong> read them into three<br />

parallel arrays, one for each language. Write a program that sorts all three<br />

arrays according to the array of English words. The program should then<br />

request an English sentence as input from the keyboard <strong>and</strong> translate it into<br />

French <strong>and</strong> German. For example, if the English sentence given is MY PENCIL<br />

IS ON THE TABLE, then the French translation will be MON CRAYON EST<br />

SUR LA TABLE, <strong>and</strong> the German translation will be MEIN BLEISTIFT IST<br />

AUF DEM TISCH.<br />

TABLE 6.10<br />

English Words <strong>and</strong> Their French <strong>and</strong> German Equivalents<br />

YES OUI JA LARGE GROS GROSS<br />

TABLE TABLE TISCH NO NON NEIN<br />

THE LA DEM HAT CHAPEAU HUT<br />

IS EST IST PENCIL CRAYON BLEISTIFT<br />

YELLOW JAUNE GELB RED ROUGE ROT<br />

FRIEND AMI FREUND ON SUR AUF<br />

SICK MALADE KRANK AUTO AUTO AUTO<br />

MY MON MEIN OFTEN SOUVENT, OFT<br />

4. Write a program that allows a list of no more than 50 soft drinks <strong>and</strong> their percent<br />

changes in market share for a particular year to be input <strong>and</strong> displays the<br />

information in two lists titled gainers <strong>and</strong> losers. Each list should be sorted by<br />

the amount of the percent change. Try your program on the data for the 8 soft<br />

drinks in Table 6.11. Note: You will need to store the data initially in an array<br />

to determine the number of gainers <strong>and</strong> losers.<br />

TABLE 6.11<br />

Changes in Market Share from 1996 to 1997 of Leading Soft-Drink Br<strong>and</strong>s<br />

Br<strong>and</strong> % Change Br<strong>and</strong> % Change<br />

in Market Share in Market Share<br />

Coke Classic –.2 Sprite .4<br />

Pepsi-Cola –.4 Dr. Pepper .1<br />

Diet Coke –.2 Diet Pepsi –.2<br />

Mt. Dew .5 7-Up 0<br />

Source: Beverage Digest, 1998<br />

5. Each team in a six-team soccer league played each other team once. Table 6.12<br />

shows the winners. Write a program to<br />

(a) Place the team names in a one-dimensional array.<br />

(b) Place the data from Table 6.12 in a two-dimensional array.<br />

(c) Place the number of games won by each team in a one-dimensional array.<br />

(d) Display a listing of the teams giving each team’s name <strong>and</strong> number of games<br />

won. The list should be in decreasing order by the number of wins.<br />

TABLE 6.12<br />

Soccer League Winners<br />

Jazz Jets Owls Rams Cubs Zips<br />

Jazz — Jazz Jazz Rams Cubs Jazz<br />

Jets Jazz — Jets Jets Cubs Zips<br />

Owls Jazz Jets — Rams Owls Owls<br />

Rams Rams Jets Rams — Rams Rams<br />

Cubs Cubs Cubs Owls Rams — Cubs<br />

Zips Jazz Zips Owls Rams Cubs —<br />

<strong>Programming</strong> Projects 211

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!