SlideShare a Scribd company logo
1 of 15
Introduction to Computers
2016-2017
Mid-Term Exam Solutions
Prepared by: Dr. Yasmine Afify
Prepared by: Dr. Yasmine Afify
Problem1
2
 Write a pseudo-code for a program that displays the
bonus for employees according to the number of years
worked. The bonus is calculated as a percentage of the
current salary as shown in table. The output should be in
the following form:
 The bonus is: 23.6 Bonus
Number of Years
5%
5
10%
10
15%
15
20%
Others
Prepared by: Dr. Yasmine Afify
Problem 1: Solution
3
BEGIN
READ years, salary
CASE OF years
= 5:
bonus = salary * 0.05
= 10:
bonus = salary * 0.1
= 15:
bonus = salary * 0.15
OTHERWISE
bonus = salary * 0.2
END-OF-CASE
PRINT “The bonus is: “ , bonus
END
Prepared by: Dr. Yasmine Afify
Problem 1: Another Solution
4
BEGIN
READ years, salary
IF years= 5 THEN
bonus = salary * 0.05
ELSE IF years= 10 THEN
bonus = salary * 0.1
ELSE IF years= 15 THEN
bonus = salary * 0.15
ELSE
bonus = salary * 0.2
END IF
PRINT “The bonus is: “ , bonus
END
Prepared by: Dr. Yasmine Afify
Problem 2
5
 Write a pseudo-code for a program that reads the number of working
years and displays the celebrated company anniversary as shown in
table. The program should also display the raise amount for its
employees, which is calculated as 10% of the number of years the
company has been in business. The output should be in the following
form:
 Silver
 The raise is : 2.5 Anniversary
Number of Years
Bronze
10
Silver
25
Golden
50
Unknown
Others
Prepared by: Dr. Yasmine Afify
Problem 2: Solution
6
BEGIN
READ years
CASE OF years
= 10:
PRINT “Bronze”
PRINT “The raise is :” , 1
= 25:
PRINT “Silver”
PRINT “The raise is :” , 2.5
= 50:
PRINT “Golden”
PRINT “The raise is :” , 5
OTHERWISE
PRINT “Unknown”
END-OF-CASE
END
Prepared by: Dr. Yasmine Afify
Problem 2: Another Solution
7
BEGIN
READ years
IF years = 10 THEN
PRINT “Bronze”
PRINT “The raise is :” , 1
ELSE IF years = 25 THEN
PRINT “Silver”
PRINT “The raise is :” , 2.5
ELSE IF years = 50 THEN
PRINT “Golden”
PRINT “The raise is :” , 5
ELSE
PRINT “Unknown”
ENDIF
END
Prepared by: Dr. Yasmine Afify
Problem 3
8
 Write the pseudo-
code for the
following flowchart,
which represents a
program that
calculates the
absolute difference
between two
numbers.
 Which statement is
executed if the user
enters equal
START
Read x, y
IS
x < y
STOP
T
F
Print diff
diff= y - x
diff= x - y
Prepared by: Dr. Yasmine Afify
Problem 3: Solution
9
BEGIN
READ x, y
IF x < y THEN
diff = y - x
ELSE
diff = x – y
ENDIF
PRINT diff
END
START
Read x, y
IS
x < y
STOP
T
F
Print diff
diff= y - x
diff= x - y
 If the user enters equal
numbers, the ELSE statement
is executed.
Prepared by: Dr. Yasmine Afify
Problem 4
10
 Write the pseudo-
code for the
following flowchart,
which represents a
program that
calculates the net
salary of an
employee based on
his job: ‘M’ for
manager and ‘E’ for
employee.
 Which statement is
executed if the user
enters ‘A’ ?
START
Read job
IS
Job =
‘M’
STOP
T
F
Print net
net = salary
+ bonus
net = salary
- tax
Prepared by: Dr. Yasmine Afify
Problem 4: Solution
11
BEGIN
READ job
IF job = ‘M’ THEN
net = salary + bonus
ELSE
net = salary - tax
ENDIF
PRINT net
END
 If the user enters ‘A’, the ELSE
statement is executed.
START
Read job
IS
Job =
‘M’
STOP
T
F
Print net
net = salary
+ bonus
net = salary
- tax
Prepared by: Dr. Yasmine Afify
Problem 5
 Draw a flowchart for the bank withdrawal process
represented by the following pseudo-code.
BEGIN
READ balance, withdrawal
IF withdrawal <= balance THEN
balance = balance - withdrawal
PRINT “Transaction Complete”
ELSE
PRINT “Insufficient Funds”
ENDIF
PRINT balance
END
Prepared by: Dr. Yasmine Afify
Problem 5: Solution
13
 Bank Withdrawal Process
13
START
Read balance,
withdrawal
Withdrawal
< balance
STOP
T
F
Print
balance
Print
“Insufficient
Funds”
Print
“Transaction
Complete”
balance = balance
- withdrawal
Prepared by: Dr. Yasmine Afify
Problem 6
14
 Draw a flowchart for a program that simulates the
doctor diagnosis. It reads a child temperature and
displays what a doctor would recommend in such
case. Doctors assume the child is healthy when his
temperature is below or exactly 37ºC. Therefore,
they recommend normal activities. However, if the
temperature is little higher than 37 ºC but still below
39 ºC, then the doctor recommends careful
observation. Otherwise, the doctors recommend that
the child should be admitted to hospital.
Prepared by: Dr. Yasmine Afify
Problem 6: Solution
15
START
Read temp
IS
temp <=
37
STOP
T
F
Print “Careful
Observation”
Print “Normal
Activities”
IS
temp <=
39
T
F
Print “Admitted
to Hospital”

More Related Content

Recently uploaded

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 

Recently uploaded (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Mid-Term Problem Solving Part.pptx

  • 1. Introduction to Computers 2016-2017 Mid-Term Exam Solutions Prepared by: Dr. Yasmine Afify
  • 2. Prepared by: Dr. Yasmine Afify Problem1 2  Write a pseudo-code for a program that displays the bonus for employees according to the number of years worked. The bonus is calculated as a percentage of the current salary as shown in table. The output should be in the following form:  The bonus is: 23.6 Bonus Number of Years 5% 5 10% 10 15% 15 20% Others
  • 3. Prepared by: Dr. Yasmine Afify Problem 1: Solution 3 BEGIN READ years, salary CASE OF years = 5: bonus = salary * 0.05 = 10: bonus = salary * 0.1 = 15: bonus = salary * 0.15 OTHERWISE bonus = salary * 0.2 END-OF-CASE PRINT “The bonus is: “ , bonus END
  • 4. Prepared by: Dr. Yasmine Afify Problem 1: Another Solution 4 BEGIN READ years, salary IF years= 5 THEN bonus = salary * 0.05 ELSE IF years= 10 THEN bonus = salary * 0.1 ELSE IF years= 15 THEN bonus = salary * 0.15 ELSE bonus = salary * 0.2 END IF PRINT “The bonus is: “ , bonus END
  • 5. Prepared by: Dr. Yasmine Afify Problem 2 5  Write a pseudo-code for a program that reads the number of working years and displays the celebrated company anniversary as shown in table. The program should also display the raise amount for its employees, which is calculated as 10% of the number of years the company has been in business. The output should be in the following form:  Silver  The raise is : 2.5 Anniversary Number of Years Bronze 10 Silver 25 Golden 50 Unknown Others
  • 6. Prepared by: Dr. Yasmine Afify Problem 2: Solution 6 BEGIN READ years CASE OF years = 10: PRINT “Bronze” PRINT “The raise is :” , 1 = 25: PRINT “Silver” PRINT “The raise is :” , 2.5 = 50: PRINT “Golden” PRINT “The raise is :” , 5 OTHERWISE PRINT “Unknown” END-OF-CASE END
  • 7. Prepared by: Dr. Yasmine Afify Problem 2: Another Solution 7 BEGIN READ years IF years = 10 THEN PRINT “Bronze” PRINT “The raise is :” , 1 ELSE IF years = 25 THEN PRINT “Silver” PRINT “The raise is :” , 2.5 ELSE IF years = 50 THEN PRINT “Golden” PRINT “The raise is :” , 5 ELSE PRINT “Unknown” ENDIF END
  • 8. Prepared by: Dr. Yasmine Afify Problem 3 8  Write the pseudo- code for the following flowchart, which represents a program that calculates the absolute difference between two numbers.  Which statement is executed if the user enters equal START Read x, y IS x < y STOP T F Print diff diff= y - x diff= x - y
  • 9. Prepared by: Dr. Yasmine Afify Problem 3: Solution 9 BEGIN READ x, y IF x < y THEN diff = y - x ELSE diff = x – y ENDIF PRINT diff END START Read x, y IS x < y STOP T F Print diff diff= y - x diff= x - y  If the user enters equal numbers, the ELSE statement is executed.
  • 10. Prepared by: Dr. Yasmine Afify Problem 4 10  Write the pseudo- code for the following flowchart, which represents a program that calculates the net salary of an employee based on his job: ‘M’ for manager and ‘E’ for employee.  Which statement is executed if the user enters ‘A’ ? START Read job IS Job = ‘M’ STOP T F Print net net = salary + bonus net = salary - tax
  • 11. Prepared by: Dr. Yasmine Afify Problem 4: Solution 11 BEGIN READ job IF job = ‘M’ THEN net = salary + bonus ELSE net = salary - tax ENDIF PRINT net END  If the user enters ‘A’, the ELSE statement is executed. START Read job IS Job = ‘M’ STOP T F Print net net = salary + bonus net = salary - tax
  • 12. Prepared by: Dr. Yasmine Afify Problem 5  Draw a flowchart for the bank withdrawal process represented by the following pseudo-code. BEGIN READ balance, withdrawal IF withdrawal <= balance THEN balance = balance - withdrawal PRINT “Transaction Complete” ELSE PRINT “Insufficient Funds” ENDIF PRINT balance END
  • 13. Prepared by: Dr. Yasmine Afify Problem 5: Solution 13  Bank Withdrawal Process 13 START Read balance, withdrawal Withdrawal < balance STOP T F Print balance Print “Insufficient Funds” Print “Transaction Complete” balance = balance - withdrawal
  • 14. Prepared by: Dr. Yasmine Afify Problem 6 14  Draw a flowchart for a program that simulates the doctor diagnosis. It reads a child temperature and displays what a doctor would recommend in such case. Doctors assume the child is healthy when his temperature is below or exactly 37ºC. Therefore, they recommend normal activities. However, if the temperature is little higher than 37 ºC but still below 39 ºC, then the doctor recommends careful observation. Otherwise, the doctors recommend that the child should be admitted to hospital.
  • 15. Prepared by: Dr. Yasmine Afify Problem 6: Solution 15 START Read temp IS temp <= 37 STOP T F Print “Careful Observation” Print “Normal Activities” IS temp <= 39 T F Print “Admitted to Hospital”