Page 6 of 6

Re: Need help with practice assignment!!

PostPosted: Tue Apr 07, 2015 5:56 am
by Robert Sample
Unless you want to make multiple passes over the table (which you don't want to do), you need one counter for each summary variable you need to print. And you need another variable to track the largest sale. All 3 variables needs to start at zero. For each entry in the table, add 1 to the number of sales. Compare the shipping to a packed decimal zero. If they are equal, add 1 to the number of records without shipping. Finally, you compare the total amount to the largest sale. If the total for this table entry is larger than the largest sale, move the total to the largest sale. When you hit the end of the table, you have the largest sale, the number of sales, and the number with no shipping charges and can then print them.

Re: Need help with practice assignment!!

PostPosted: Tue Apr 07, 2015 7:13 am
by pintu1228
ok i tried to do the counter for the sales and average total cost but dont understand how to implement these.

Can you provide with some code so I can go off of that and work the rest.


Thanks

Re: Need help with practice assignment!!

PostPosted: Tue Apr 07, 2015 7:36 am
by Robert Sample
For the number of sales without shipping charges, in your TLOOP you need:
         CP    $TSHIP,ZERO
         BNE   CHKLARGE
         AP    NONOSHIP,=PL1'1'
CHKLARGE EQU   *
.
.
.
ZERO     DC    PL2'0'
NONOSHIP DC    PL2'0'
and you need to do a compare after the CHKLARGE, then a move. Before the CP in the code, you could count the number of sales; if you do that after starting the compares make sure you count every record. NONOSHIP is the number of records with no shipping charge.

Re: Need help with practice assignment!!

PostPosted: Tue Apr 07, 2015 7:52 am
by pintu1228
thanks,

what are we comparing after BNE CHKLARGE?

Re: Need help with practice assignment!!

PostPosted: Tue Apr 07, 2015 8:02 am
by pintu1228
ok im having some trouble with printing my shipping charges, I have enough pattern and ED but nothing shows up.

Also my total is not printing in the correction location.


I tried doing the number with no shipping but am i missing something?


Thanks

Re: Need help with practice assignment!!

PostPosted: Tue Apr 07, 2015 8:35 am
by Robert Sample
While it is not necessarily a bad thing to put explicit lengths on your instructions, your ZAP $TSHIP instructions in lines 134 and 137 USE THE WRONG LENGTH. Each of them output a 4-byte packed decimal $TSHIP variable. Since $TSHIP is only defined as 2 bytes, what happens? The 3rd and 4th bytes are stored immediately after $TSHIP. Line 141 where you ZAP $TTOTAL then destroys the shipping charge value since the 2 bytes after $TSHIP are the first 2 bytes of $TTOTAL. The net result is your shipping charges are zero for every record.

And I don't understand what you mean by "my total is not printing in the correction location". Based upon the code you have, the values being printed are perfectly correct. The trailing 5 is being printed because Assist initialized memory for you and you did not define 133 bytes after PLINE even though you print 133 bytes -- hence you get unused memory locations printing. And $TTOTAL is defined as PL5 which means your edit mask needs 9 digits to print correctly -- and you did not define 9 digits in your edit mask.

And, also, you did not copy and paste my code correctly -- your code will add 1 to NONOSHIP no matter what the shipping charges are. Details are critically important in IT (even more so in Assembler) and you have shown a distressing lack of concern about those details -- you have been told repeatedly about errors in your code and calculations yet those errors are still present in your code. You need to go back to the very first post in this thread and re-read every post ensuring as you do that any recommended changes have been made in your code.

I believe it is time for you to polish off the rest of the code yourself -- there's not much left to be done and if you pay attention to the details you should be able to get a complete, working program within an hour or two. If you don't pay attention to the details, you will NEVER get a working program done.