Sei sulla pagina 1di 2

AMAT 150

Programming Exercises Control Structures


Guidelines

This set of exercises will let the students be able to construct expressions to evaluate given
condition, construct if statements to perform specified tasks, and construct loop statements.
This set of exercises can be by pair or individual.
Follow the other specifications detailed at the end of the activities.
Important: You programs will be graded according to the criteria (check course syllabus).
Implement the necessary elements to meet the criteria.

Activity A. Write a program for a simple calculator with a process shown by the sample
program run below:
This program is for a simple calculator
Enter 1st num: 3
Enter 2nd num: 5
Choose operation:
[1] Addition
[2] Subtraction
[3] Multiplication
[4] Division
[5] New Inputs
[0] Exit
Choice: 1
Sum is 8
Choose operation:
[1] Addition
[2] Subtraction
[3] Multiplication
[4] Division
[5] New Inputs
[0] Exit
Choice: 2
Difference is -2
Choose operation:
[1] Addition
[2] Subtraction
[3] Multiplication
[4] Division
[5] New Inputs
[0] Exit
Choice: 4
Quotient is 0
Choose operation:
[1] Addition
[2] Subtraction

[3] Multiplication
[4] Division
[5] New Inputs
[0] Exit
Choice: 5
Enter 1st num: 15
Enter 2nd num: 3
Choose operation:
[1] Addition
[2] Subtraction
[3] Multiplication
[4] Division
[5] New Inputs
[0] Exit
Choice: 4
Quotient is 5
Choose operation:
[1] Addition
[2] Subtraction
[3] Multiplication
[4] Division
[5] New Inputs
[0] Exit
Choice: 0
Program terminated. Thank you for using the program.

Activity B. You've been hired by a law firm that is working on a sex discrimination case. You
are given a record containing the salaries of the employees in the company being sued. As a
first pass in the analysis of the data, you've been asked to compute the average income for
females and the average income for males. Thus, you are tasked to create a program that will
ask for the salaries of the employees and then compute and display the average income of a
male employee and a female employee. Write the program. Note that average values should be
correct to up to two digits after the decimal point.
Submission:
Only the source codes are to be submitted. Name your program source code files should be
either of the formats:
o Individual: Surname_A and Surname_B for Activity A and Activity B, respectively.
Note that you are to replace Surname with the correct surname.
o Pair: Surname1_Surname2_A and Surname1_Surname2_B for Activity A and
Activity B, respectively. Note that you are to replace Surname1 and Surname2 with
the correct surnames.
The files are to be emailed to me (instructor.upmin@gmail.com) before 10am of 08 July
2015. Late submissions will gain no credit.

Potrebbero piacerti anche