c++ - Visual Studio Programming -


i have assignment not understanding. focusing on for, while, , while statements chapter. question goes follows...

"the payroll manager @ kenton incorporated wants program allows him enter unknown number of payroll amounts each of 3 stores: store 1, store 2, , store 3. program should calculate total payroll , display te result on screen."

i lost on start. guess confusing me "an unknown number of payroll amounts". don't know how make user transistion entering next stores payroll amounts. question says nothings using sentinel value, doesn't not use sentinel value.

any or advice appreciated!!!!

since there 3 stores, may want keep payroll amounts each separate though specs don't seem care. way can use special store code of 0 indicate you're done.

pseudo-code follows:

store1 = 0 store2 = 0 store3 = 0 print "enter store, or 0 end: " input storenum while storenum <> 0:     print "enter payroll amount: "     input amount     select storenum:         case 1:             store1 += amount             end case         case 2:             store2 += amount             end case         case 3:             store3 += amount             end case     end select     print     print "enter store # or 0 end"     input storenum end while print print "store 1 payroll ", store1 print "store 2 payroll ", store2 print "store 3 payroll ", store3 print print "total payroll ", store1 + store2 + store3 

that lead transcript like:

enter store, or 0 end: 3 enter payroll amount: 33  enter store, or 0 end: 2 enter payroll amount: 22  enter store, or 0 end: 3 enter payroll amount: 11  enter store, or 0 end: 0  store 1 payroll 0 store 2 payroll 22 store 3 payroll 44  total payroll 66 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -