Introduction to Computer Science - Algorithms for Problem Solving

Verified

Added on  2023/04/24

|11
|974
|222
AI Summary
This document discusses various algorithms for problem solving in computer science. It includes pseudo code algorithms and desk checks for solution algorithms. The algorithms covered include those for calculating commission, computing grade letters, and calculating income tax. The document also includes a bibliography of relevant research on the topic.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Running head: INTRODUCTION TO COMPUTER SCIENCE
Introduction to Computer Science
Name of the Student
Name of the University
Author’s Note

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
1
INTRODUCTION TO COMPUTER SCIENCE
Solution Algorithm 1:
Defining Problem:
Input Processing Output
Recording transaction
Retail_cost
Transaction_code
Employee_No.
Reading transaction
Calculating commission
Printing details of
transaction
Retail cost
Commission
Employee No.
Pseudo code algorithm:
If the case of solution is not A, B or C then a message is printed and commission set
as 0.
Process transaction record
Read retail_cost, transaction_code and employee_no.
CASE Transaction_Code
A: Commission = retail_cost x 0.06
B: Commission = retail_cost x 0.08
C: Commission = retail_cost x 0.1
Other: Displaying ‘Invalid transaction’, Transaction_code commission = 0
END CASE
Print ‘Retail Price’, retail_cost, ‘Commission’, commission, ‘Employee No.’, Employee_No.
END
Document Page
2
INTRODUCTION TO COMPUTER SCIENCE
Desk check of the algorithm:
1. INPUT:
1st Set of Data 2nd Set of Data
Retail_cost 50$ ABC
Transaction_code A C
Employee_No. 12345 34567
2. Result Expected
1st Set of Data 2nd Set of Data
Commission 3$ ERROR
3. Check Table
Statement No. Retail_Price Transaction_Cod
e
Emloyee_No. Commission
1st Pass
1. 50$ A 12345
2. 3$
3. Print
2nd Pass
1. ABC C 34567
2. ERROR
3. Print
Document Page
3
INTRODUCTION TO COMPUTER SCIENCE
Solution Algorithm 2:
Defining Problem:
Input Processing Output
serial_no. Analyse student record serial_no.
exam_point Computing grade_letter exam_point
Print detailed result grade_letter
Pseudo code algorithm:
Using nested IF framework and CASE statement
Process_student_grade_letter
Read_student_serial_no., student_exam_marks
CASE of grade_letter
HD: exam_marks>84
D: exam_marks>74
C: exam_marks>64
P: exam_marks>59
F: exam_marks<50
ENDCASE
Print student_serial_no., exam_marks, grade_letter

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
4
INTRODUCTION TO COMPUTER SCIENCE
End
Using linear nested IF statement:
Process_student_grade_letter
Read_student_serial_no., student_exam_marks
IF exam_marks > ’84’ THEN
exam_marks = HD
ELSE
IF exam_marks > ’74’; THEN
exam_marks = D
ELSE
IF exam_marks > ‘64’ THEN
exam_marks = C
ELSE
IF exam_marks > ‘59’ THEN
exam_marks = P
ELSE
IF exam_marks < ‘50’ THEN
exam_marks = F
ENDIF
ENDIF
Document Page
5
INTRODUCTION TO COMPUTER SCIENCE
ENDIF
ENDIF
ENDIF
exam_marks = grade_letter
Print student_serial_no., exam_marks, grade_letter
End
Desk check of the algorithm:
1. INPUT:
1st set of data 2nd Set of data
Exam_marks 77 AD
Grade_letter D HD
2. Result Expected
1st set of data 2nd Set of data
Exam_marks 77 Invalid
Grade_letter D HD
3. Check Table
Statement exam_marks Grade_ letter Execution of CASE statement
1st Pass
Document Page
6
INTRODUCTION TO COMPUTER SCIENCE
Read 77
CASE CASE D
Grade_letter D
Print yes yes
2nd Pass
Read AD
CASE
Grade_letter
Print yes yes
Solution Algorithm 3:
Defining Problem:
Two integer items are taken into a loop using an array for calculating the income from
the user and computing the income tax and displaying the income tax. The chargeable
income, income tax and gross tax payable is analysed for checking the validation and
optimizing the codes.
Input Processing Output
Integer 1
Integer 2
Sum
Difference
Display

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7
INTRODUCTION TO COMPUTER SCIENCE
Product
Quotient
Pseudo code algorithm:
Calculating_payable_tax
Prompt for income
Get income
If (income >=0 & income <=20,000) then
Print Tax = 0
Else if (income >= 20,000 & income <=30,000)
Then
Print tax = 0 + (income -20,000) *2%
Else if (income >= 30,000 & income <=40,000)
Then
Print tax = 200+ (income – 30,000) *3.5%
Else if (income >= 40,000 & income <=80,000)
Then
Print tax = 550+ (income – 40,000) * 7%
Else if (income >= 80,000 & income <=120,000)
Then
Print tax = 3,350+ (income – 80,000) *11.5%
Document Page
8
INTRODUCTION TO COMPUTER SCIENCE
Else if (income >= 120,000 & income <=160,000)
Then
Print tax = 7,950+ (income – 120,000) *15%
Else if (income >= 160,000 & income <=200,000)
Then
Print tax = 13,950+ (income – 160,000) *17%
Else if (income >= 200,000 & income <=320,000)
Then
Print tax = 20,750+ (income – 200,000) *18%
Else if (income >= 320,000)
Then
Print tax = 42,350+ (income – 320,000) *20%
Desk check of the algorithm:
1. INPUT:
1st Set of Data 2nd Set of Data
income 320,500 AB
income 160,500 0
2. Result Expected:
1st Set of Data 2nd Set of Data
Tax 50,920 Error
Tax 16406.5 Error
Document Page
9
INTRODUCTION TO COMPUTER SCIENCE
3. Check Table:
Statement Income Tax
1st Pass
1, 2 Get /Prompt 320500
3 Check
4 Calculate
5 Print 50,920
2nd Pass
1, 2 Get /Prompt AB
3 Check
4 Calculate
5 Print Error

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
10
INTRODUCTION TO COMPUTER SCIENCE
Bibliography
Adulyasak, Y., Cordeau, J. F., & Jans, R. (2015). The production routing problem: A review
of formulations and solution algorithms. Computers & Operations Research, 55, 141-
152.
Gunawan, A., Lau, H. C., & Vansteenwegen, P. (2016). Orienteering problem: A survey of
recent variants, solution approaches and applications. European Journal of
Operational Research, 255(2), 315-332.
1 out of 11
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]