Title | ICS - Assignment 1 - fdsfsd |
---|---|
Course | Inforcom |
Institution | Babu Banarasi Das University |
Pages | 7 |
File Size | 282.9 KB |
File Type | |
Total Downloads | 81 |
Total Views | 130 |
fdsfsd...
Introduction to Computer Science Assignment 1: Individual Assignment 1. A transaction record on a sales commission file contains the retail price of an item sold, a transaction code that indicates the sales commission category to which an item can belong, and the employee number of the person who sold the item. The transaction code can contain the values A, B or C, which indicate that the percentage commission will be 6%, 8% or 10% respectively. Construct an algorithm that will read a record on the file, calculate the commission owing for that record and print the retail price, commission and employee number. (8 marks) Answer: Empno
Empno
RP
RP
Transcode
Comms
Defining Diagram: INPUT Empno Transcode RP
PROCESSING Read Record Calculate Comm Print Empno, Comm, RP
Algorithm: 1. 2. 3. 4.
5.
6. 7. 8.
Read record Dowhile (Not EOF) Set msg to blank IF (Transcode == A) then Comm = RP * 6% ElseIF (Transcode == B) then Comm = RP * 8% ElseIF (Transcode == C) then Comm = RP * 10% Else Msg = ‘Transaction Code Invalid’ ENDIF ENDIF ENDIF IF (msg == blank) then Print RP, Comm, Empno Else Print ‘Transaction Code Invalid’ EndIF Read next record EndDO End
OUTPUT Empno Comm RP
Desk Check: Input Data 1ST Record 021 A 250
Empno Transcode RP
2nd Record 075 C 635
3 rd Record 035 H 35
4th Record EOF
Expected Results 1ST Record 021 15 250
Empno Comm RP Msg
2nd Record 075 63.50 635
3rd Record
4TH Record
Transaction Code Invalid
Desk Check Table: Statement No 1st Pass 1 2 3 4 5 6 2 3 4 5 6 2 3 4 5 6 2
Empno
Transcode
RP
021
A
250
Comm
Msg
Dowhile
True Blank Print 075
C
Print 635
15 Print True Blank
Print 035
H
Print 35
63.50 Print True Blank Transaction Code Invalid Print
EOF False
2. Design an algorithm that will prompt an operator for a student’s serial number and the student’s exam score out of 100. Your program is then to match the exam score to a letter grade and print the grade to the screen. Calculate the letter grade as follows: Exam Score 85 and above 75-84 65-74 50-64 Below 50
Assigned Grade HD D C P F
Answer: Serial Score
Grade
Defining Diagram: INPUT Serial Score
PROCESSING Prompt for Serial, Score Get Serial, Score Calculate Grade Print Grade
Algorithm: 1. Prompt for Serial, Score 2. Get Serial, Score 3. If (Score < 0 and Score > 100) then Grade = ‘Invalid Score’ ElseIF (Score >= 85 and Score = 75 and Score = 65 and Score = 50 and Score = 0 and Score 0 and Income 20000 and Income 30000 and Income 40000 and Income 80000 and Income 120000 and Income 160000 and Income 200000 and Income 240000 and Income 280000 and Income 320000) then Remainder = Income -320000 Tax = 44550 + (Remainder * 22%) ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF
4. 5.
ENDIF Display Income, Tax End
Desk Check: Input Data Input Income
1st Data Set 845000
2nd Data Set -57000
1st Data Set 845000 160050
2nd Data Set -57000 Invalid Number
Expected Result Output Income Tax Desk Check Table Sequence No. 1st Pass 1,2 3 4 2nd Pass 1,2 3 4
Income
Tax
845000 Display
160050 Display
-57000 Display
Invalid Number Display...