Home HTML →True Basic →Chapter 1 →Chapter 1_2 →Chapter 2 →Chapter 3 →Chapter 4 →Chapter 5 →Linear Functions Program Article Reviews |
!Jeremy Fallick !January 3, 2005 !Period 6 !Chapter 4, Problem 1 Read M Read N For integer = M to N let square = integer^2 let sum = sum + square Next integer print "The sum is"; sum Data 1,10 End !Jeremy Fallick !January 5, 2005 !Period 6 !Chapter 4, Problem 2 INPUT prompt "Number of integers:":n FOR integer = 1 to n LET square = integer^2 LET sum = sum + square NEXT integer LET average=sum/n PRINT "The average of the squares of the first";n;"positive integers is"; average END !Jeremy Fallick !January 5, 2005 !Period 6 !Chapter 4, Problem 3 INPUT prompt "Number of integers:":n let factorial = 1 FOR integer = 1 to n LET factorial = factorial * integer NEXT integer PRINT n; "!="; factorial END !Jeremy Fallick !January 5, 2005 !Period 6 !Chapter 4, Problem 4 INPUT prompt "Number of integers:":m let factorial = 1 print " n ","n factorial" print "-----------","-----------" FOR n = 1 to m LET factorial = factorial * n print n,factorial NEXT n END !Jeremy Fallick !January 5, 2005 !Period 6 !Chapter 4, Problem 5 input prompt "Temperature in Celsius:":Celsius do until Celsius=-999 let Fahrenheit= 9*Celsius/5+32 print Celsius; "degrees Celsius equals"; Fahrenheit; "degrees Fahrenheit." input prompt "Temperature in Celsius:":Celsius loop end !Jeremy Fallick !January 5, 2005 !Period 6 !Chapter 4, Problem 6 do until UCASE$(employee$)="Z" and age=0 read employee$, age let sum=sum+age let loops=loops+1 loop let average=sum/(loops-1) print "The average employee age is"; average; "years." data "Ann Bartlett", 37 data "John Franco", 48 data "Jane Morgan", 28 data "Albert Smythe", 40 data "Mary Wilson", 62 data "Z", 0 end !Jeremy Fallick !January 5, 2005 !Period 6 !Chapter 4, Problem 7 input prompt "Player's Name:": name$ do while UCASE$(name$)<>"ZZZ" input prompt "Number of at bats:": atbats input prompt "Number of singles:": singles input prompt "Number of doubles:": doubles input prompt "Number of triples:": triples input prompt "Number of home runs:": homeruns let battingaverage=(singles + doubles + triples + homeruns) / atbats let sluggingpercentage=(singles + 2 * doubles + 3 * triples + 4 * homeruns) / atbats print using "This player's batting average is #.###": battingaverage print using "This player's slugging percentage is #.###": sluggingpercentage input prompt "Player's Name:": name$ loop end !Jeremy Fallick !January 7, 2005 !Period 6 !Chapter 4, Problem 8 READ name$ DO until UCASE$(name$)="ZZZ" READ number FOR count=1 to number READ score LET total=total+score NEXT count LET average=total/number LET averagetotal=averagetotal+average PRINT name$; "'s average score is"; average; "." LET count=count+1 let total=0 READ name$ LOOP let classaverage=averagetotal/count PRINT "The class average score is"; classaverage; "." DATA "Jeremy Fallick",3,100,85,100 DATA "David Tao",4,0,5,0,67.8 DATA "Shaun Flynn",5,80,60,70,5,9.24 DATA "James Street",6,100,50,2.5,19,63,81 DATA "ZZZ",0 END !Jeremy Fallick !January 11, 2005 !Period 6 !Chapter 4, Problem 9 input prompt "Term:":term input prompt "Number of yearly compoundings:":num print " 7% "," 7.5% "," 8% "," 8.5% "," 9% " print "-----------","-----------","-----------","-----------","-----------" for principal=500 to 10000 step 500 let rate=K let amount0 = principal * (1 + .01 * rate / num) ^ (num * term) let rate=K+.5 let amount0_5 = principal * (1 + .01 * rate / num) ^ (num * term) let rate=K+1 let amount1 = principal * (1 + .01 * rate / num) ^ (num * term) let rate=K+1.5 let amount1_5 = principal * (1 + .01 * rate / num) ^ (num * term) let rate=K+2 let amount2 = principal * (1 + .01 * rate / num) ^ (num * term) print amount7,amount7_5,amount8,amount8_5,amount9 next principal end !Jeremy Fallick !January 12, 2005 !Period 6 !Chapter 4, Problem 10 do until UCASE$(again$)="NO" input prompt "Initial rate:":initial input prompt "Term:":term input prompt "Number of yearly compoundings:":num print " 7% "," 7.5% "," 8% "," 8.5% "," 9% " print "-----------","-----------","-----------","-----------","-----------" for principal=500 to 10000 step 500 for rate=initial to initial+2 step .5 let amount=principal*(1+rate/num)^(num*term) print "$";amount, next rate next principal input prompt "Again?(Yes/No)":again$ loop end !Jeremy Fallick !January 17,2005 !Period 6 !Chapter 4, Problem 11 do until ucase$(yesno$)="N" input prompt "Asset name:":name$ input prompt "Cost:":cost input prompt "Salvage value:":value input prompt "Useful life:":life let depreciation=(cost-value)/life print "For ";name$;" with a cost of";cost;", a salvage value of";value;"and a useful life of";life;", the yearly depreciation is";depreciation input prompt "Again?(y/n)":yesno$ loop end !Jeremy Fallick !January 17,2005 !Period 6 !Chapter 4, Problem 12 do until ucase$(yesno$)="N" input prompt "Asset name:":name$ input prompt "Cost:":cost input prompt "Salvage value:":value input prompt "Useful life:":life let depreciation=(cost-value)/life print "Year","Yearly Depreciation","Accumulated Depreciation","Current Value of Asset" print "----","-------------------","------------------------","----------------------" for year=1 to life let accumulation=depreciation*year let currentvalue=cost-accumulation print year,depreciation," ",accumulation," ",currentvalue next year input prompt "Again?(y/n)":yesno$ loop end |