{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

(CIS110 -Cmptr Prgrmmng Dsgn) Week 7 Assignment

(CIS110 -Cmptr Prgrmmng Dsgn) Week 7 Assignment - S h a n...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: - S h a n na Ha w xhu rst Exercise # 3 : Sum of Numbers // D e cl a re a n in p u t f il e D e cl a re In p u tFi le nu mb e rsFil e // V a ria b l e to h ol d th e n u mbe r re a d f ro m the fi le D e cl a re In te g e r nu mb e r // A ccu mul a to r to ho l d /a dd to tal nu mb e rs D e cl a re In te g e r to ta l = 0 O pe n n u mb e rsFi le “n u mb e rs.da t” // R ea d th e nu mbe rs an d ca l cul a te th e to ta l Wh i le no t eo f(n u mbe rsFi l e) // R ea d a nu mbe r R ea d n u mbe rsFi l e n u mb e r // A d d n u mb e r to to tal S e t to tal = to ta l + nu mb e r E n d Wh il e Cl o se n u mb e rsFi le // D i sp l a y th e to ta l o f the nu mb e rs ad d e d to ge th e r. D i sp l a y “Th e to ta l o f the nu mb e rs i s”, to ta l , “.” E xercise #4 : Average of Numbers // D e cl a re a n in p u t f il e D e cl a re In p u tFi le nu mb e rsFil e // V a ria b l e to h ol d th e n u mbe r re a d f ro m the fi le D e cl a re In te g e r nu mb e r // A ccu mul a to r to ho l d n u mb e rs a d de d a n d on e to ho ld th e qu a n ti ty of nu mb e rs D e cl a re In te g e r su mme d Nu mb e rs = 0 D e cl a re In te g e r qu a n ti tyN u mb e rs = 0 O pe n n u mb e rsFi le “n u mb e rs.da t” // R ea d th e nu mbe rs, ca l cu l a te th e to ta l , an d th e n ge t th e a ve ra g e . Wh i le no t eo f(n u mbe rsFi l e) // R ea d a nu mbe r R ea d n u mbe rsFi l e n u mb e r // A d d n u mb e r to the su mme d n u mbe rs an d q ua n ti ty of n u mb e rs. S e t su mme d Nu mb e rs = su mme dN u mbe rs + n u mb e r S e t qu a n ti tyNu mb e rs = qu a n ti tyNu mb e rs + 1 E n d Wh il e Cl o se n u mb e rsFi le // D i sp l a y th e ca l cu l a te d a ve ra ge of th e n u mb e rs. D i sp l a y “ T he ca l cul a te d a ve ra g e o f th e n u mbe rs is”, D i sp l a y “ su mme dN u mbe rs/q u a n ti tyN u mb e rs, “.” ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online