Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 9th, 2008, 07:36 PM
ccfc1986 ccfc1986 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 16 ccfc1986 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 24 m 45 sec
Reputation Power: 0
Help with program - input data and wages

Hey all i have to write a program in assembler that basicaly reads in a list of employee information till EOF and does some simple calculations and prints the result. I am reading in the following from an external data file:
employee number, hourly wage (in cents), hours worked, bonus (in cents), deduction (in cents).

These things are then used to calculate the GROSS PAY and NET PAY. To get gross pay, i first have to use an IF to check if hours worked is greater than 40... if it is, i do the following:
(40 * wage) + (hours worked - 40) * (wage * 2)
else (hours less than 40)
hours worked * wage
So thats how gross pay is figured...

Then i have to do this:
GROSS PAY - DEDUCTIONS
GROSS PAY + BONUS
This will give me the NET PAY.

I have the following code... plz take a look and see if anything looks off or if something could be made simpler...

Code:
ASSIGN4  CSECT
         USING     ASSIGN4,15     Establish addressability
         XPRNT     PGHDR,72       Prints main header
         XPRNT     HDR2,72        first line of header
         XPRNT     HDR3,72        second line of header
         XREAD     BUFFER,80      Reads 1st line
*         SR        8,8
*         SR        10,10
DO1      BC        B'0100',ENDDO1 while (!= EOF)
         XDECI     2,BUFFER       Stores emp. number in R2
         XDECI     4,0(,1)        hourly wage in cents in R4
         XDECI     6,0(,1)        hours worked in R6
         XDECI     12,0(,1)        bonus in R8
         XDECI     13,0(,1)       deductions in R10
         LR        8,4            loads copy of wage into R8
         LR        10,6           load copy of hours into R10
IF1      C         6,FORTY        compares R6 > 40
         BC        B'1101',ELSE1  IF R6 > 40
         M         4,=F'40'        mult. wage * 40
         M         8,=F'2'        mult. wage * 2
         S         10,=F'40'       subtract 40 from hours worked
         MR        10,8           calculates overtime pay
         AR        4,10           adds basic hour pay to overt pay
         D         8,=F'2'        gets original hourly wage
         BC        B'1111',ENDIF1
ELSE1    DS        0H             ELSE R6 < 40
         MR        4,6            hours worked * hourly pay
ENDIF1   DS        0H             ENDIF
         XDECO     4,GROSSPAY     R4 stored in gross pay
         AR        4,8            add bonus to gross pay
         SR        4,10           subtract deductions from gross pay
         XDECO     4,NETPAY      R6 stored in netpay        
         XDECO     8,WAGE         R8 stored in wage
         XDECO     6,HOURS       R6 stored in hours
         XDECO     2,EMPNUM      R2 stored in emp. number
         XDECO     12,BONUS        Stores R5 into new cost of car
         XDECO     13,DEDUCT      stores r10 in deduct
         XPRNT     PLINE,70       prints each data line
         SR        8,8             ddd
         SR        10,10           ddd
         SR        12,12            ddd 
         SR        13,13           dddddd
         XREAD     BUFFER,80      reads next line of data
         BC        B'1111',DO1    loops if not end of file
ENDDO1   DS        0H             loop exit
         BCR       B'1111',14     exit
         SPACE     2
***********************************************************************
*                                                                     *  
**************************** STORAGE AREA *****************************
*                                                                     *
***********************************************************************
         SPACE     2
*BASIC CONSTANTS DEFINED BELOW
BUFFER   DS        CL80           Allocated memory for readin
FORTY   DS        F'40'          hours worked = 40
TOTEMP   DS        CL6            total number of employees
AVEPAY   DS        CL6            average net pay per employee
*
         SPACE     2
*PAGE HEADER PRINTS HERE
PGHDR    DC        C' '                 Header
         DC        CL18' '              blank space
         DC        C'PAYROLL REPORT -- JOHN JONES WIDGET COMPNAY'
HDR2     DC        C' '                Columns
         DC        C'EMPLOYEE'         column header
         DC        CL4' '              blank space
         DC        C'HOURLY'           column header
         DC        CL4' '              blank spaces
         DC        C'HOURS'            column header
         DC        CL32' '             blank spaces
         DC        C'GROSS'            column header
         DC        CL2' '              blank spaces
         DC        C'NET'              column header 
HDR3     DC        C' '                columns
         DC        C'NUMBER'           column header
         DC        CL6' '              blank space
         DC        C'WAGE'             column header
         DC        CL6' '              blank space
         DC        C'WORKED'           column header 
         DC        CL6' '              blank space
         DC        C'BONUS'            column header
         DC        CL6' '              blank space
         DC        C'DEDUCTIONS'       column header
         DC        CL4' '              blank space
         DC        C'PAY'              column header
         DC        CL4' '              blank space
         DC        C'PAY'              column header
         SPACE     2
*EACH LINE OF DATA PRINTS HERE
PLINE    DC        C' '          start of line data
         DC        CL1' '
GROSSPAY DS        CL6          emp number
         DC        CL6' '       spaces x 5
WAGE     DS        CL6          wage hourly
         DC        CL4' '       space x 5
NETPAY   DS        CL6          hours worked  
         DC        CL4' '       space x 5
BONUS    DS        CL6          bonus  
         DC        CL6' '       space x 5
DEDUCT   DS        CL6          deductions
         DC        CL4' '       space x 5
EMPNUM   DS        CL6          gross pay  
         DC        CL4' '       space x 5
HOURS    DS        CL6          net pay
         EJECT
         END       ASSIGN4        end


And the output is this:

PAYROLL REPORT -- JOHN JONES WIDGET COMPNAY EMPLOYEE
EMPLOYEE HOURLY HOURS GROSS NET N
NUMBER WAGE WORKED BONUS DEDUCTIONS PAY PAY
-2 0 12000 11300 123456
9 0 1500 21400 841817
-1 0 10500 12000 578382
7 0 9500 9735 328947
-15 0 - 1850 5580 829030

The numbers are displayed in the wrong colums as i was testing some things... the items are in this order:
gross pay, wage, net pay, bonus (the 12000 column), deductions (the 11300 column), emp. number (the 123456 column), hours.

So obviously a colum is missing, probably due to the spacing etc... any ideas?

Hope someone could lend a hand. Thank you!

Last edited by ccfc1986 : July 9th, 2008 at 07:38 PM. Reason: wrong output

Reply With Quote
  #2  
Old August 1st, 2008, 12:12 PM
griefers griefers is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Location: Waterloo
Posts: 48 griefers User rank is Sergeant (500 - 2000 Reputation Level)griefers User rank is Sergeant (500 - 2000 Reputation Level)griefers User rank is Sergeant (500 - 2000 Reputation Level)griefers User rank is Sergeant (500 - 2000 Reputation Level)griefers User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 16 h 39 m 48 sec
Reputation Power: 10
Quote:
Originally Posted by ccfc1986

So obviously a colum is missing, probably due to the spacing etc... any ideas?

Hope someone could lend a hand. Thank you!


Add in another column?

What exactly are you asking for help with here? You obviously know how to format the output file and you have written code to supposedly do all the calculations. Are the numbers not coming out correct? Did you mess up some logic so it doesn't work properly? Please be a little more specific with what you need a hand with.

Reply With Quote
  #3  
Old August 3rd, 2008, 03:40 PM
Schol-R-LEA's Avatar
Schol-R-LEA Schol-R-LEA is offline
Commie Mutant Traitor
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Location: The People's Republic of Berkeley
Posts: 1,215 Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level)Schol-R-LEA User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 10 h 4 m 17 sec
Reputation Power: 574
I would add that you neglected to include two important pieces of information, ones which are possible to skip with most languages but not with any form assembly language: the CPU and assembler it is for. After an educated guess or two and a bit of checking, I figured that it was IBM z-System High-Level Assembler (HLASM), which few if any of the coders here are going to be familiar with (though some of the older ones may know BAL, the assembler for the z-System's predecessor, the System/370). You may want to check a group that is specific to IBM mainframe programming, such as comp.lang.as370, to be honest (though that newsgroup appears to be moribund from the lack of recent postings). There just aren't that many mainframe assembly programmers around these days.

Also - and I say this in light of not only this post but another one I stumbled on while looking up information on the topic which looks like it may have been posted in another group by you, on the same general topic but asking a more basic question - you may want to read 'How to Ask Questions the Smart Way' by Eric S. Raymond. While your questions haven't been unintelligent, you appear to be a relative newcomer to technical message boards, and could probably benefit from the advice he gives. It should make things go more smoothly in the future. HTH.
__________________
Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
#define KINSEY (rand() % 7) λ Scheme is the Red Pill
Scheme in ShortUnderstanding the C/C++ Preprocessor
Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

Last edited by Schol-R-LEA : August 3rd, 2008 at 04:17 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Help with program - input data and wages


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT