Unit 3 Assignment: Loops and Arrays

raybetts1
CIS216Unit3AssignmentRev.pdf

Due Date: 11:59 p.m. EST, Sunday of Unit 3

Points: 100

Overview:

In this assignment, you will be analyzing how to use a loop control variable, create

nested loops, avoid common loop mistakes, use constants with arrays, search an array

for an exact match, and use parallel arrays.

Instructions:

Complete the following programming exercises:

1. Design an algorithm for a program that asks the user to enter an integer value

between 1 and 100, inclusive. The program should use an input validation loop

to make sure that the user has entered a value within the correct range. Once

the user has entered a value within the correct range, the program should

congratulate the user and display the value the user has entered. Use the

constants MIN = 0 and MAX = 100 in the algorithm design.

What is the advantage of using constants?

2. Design an algorithm that asks a user to enter their exercise goal for the week in

minutes. The program should then ask the user to enter the number of minutes

that have exercised over the past seven days. The program should display the

goal and the actual number of minutes exercised. If the user has met or

exceeded their goal the program should display a congratulatory message.

Otherwise, the program should display a message encouraging the user to try

harder next week

3. Design an algorithm for a program that helps a teacher determine the average

grade for her students. For each student in the class, the teacher will input the

student’s name and three test scores (use a for loop to input the three test

scores). The program should use an input validation loop similar to that in

Progam 3.1 to ensure that the grades entered are between 0 and 100, inclusive.

The program should calculate the student’s average grade and display the

student’s name and average grade. A student name of “XX” signifies the end of

the student grade processing. Once all of the students’ information has been

entered, the program should display the number of students and the overall

average grade for all of the students should be displayed.

What type of loop is being used to process all of the students’ grades? What is

the value “XX” called?

4. Design an algorithm for a program That asks the user to enter ten numbers that

will be stored in an array (Hint: for loop). After the user has entered the ten

numbers the program should find and display the sum of all of the numbers, the

average of all of the numbers, the lowest value of all of the numbers, and the

highest value of all of the numbers.

5. Roy L. Fuchs used car emporium needs a program to help it find the commission

for all of its salespersons for the month. The program should use parallel arrays,

“names”, “sales_totals”, and “commission” to store the employees’ names, total

sales for the month, and the commission amount earned. Develop an algorithm

for a program that asks the user to enter up to ten employee names and saves

the names in the “names” array. Note: there may be less than 10 employees.

The program should then display each employee’s name and asks the user to

enter the total dollar amount of sales for each employee ($0.00 to $100,000.00)

and stores this value in the “sales_total” array. The program should then

calculate the amount of commission, based on the table below, and store the

value in the “commission” array. Lastly, the program should display each

employee’s name and the amount of commission that the employee has earned

for the month.

Sales Amount Commission Rate

$ 0.00 - $ 30,000.00 4%

$ 30,000.01 - $ 60,000.00 8%

$ 60,000.01 - $ 75,000.00 10%

$ 75,000.01 - $ 100,000.00 12%

Requirements:

• Show your work in a Word document.

o Include all your work for each question.

o You can include screenshots of work done on paper.

• For all justification exercises, remember to use the definitions and principles that

we have learned thus far.

Be sure to read the criteria by which your work will be evaluated before you start

and again after before you submit it.

Evaluation Rubric for Loops and Arrays Assignment

CRITERIA Deficient Needs

Improvement Proficient Exemplary

(0-10 Points) (11 - 14 Points) (15-19 Points) (20 Points)

Program #1 The program is missing or does

not meet any of

the program

requirements.

Some program

requirements are

met.

Most program

requirements

are met.

All program

requirements

are met.

Program #2 The program is missing or does

not meet any of

the program

requirements.

Some program

requirements are

met.

Most program

requirements

are met.

All program

requirements

are met.

Program #3 The program is missing or does

not meet any of

the program

requirements.

Some program

requirements are

met.

Most program

requirements

are met.

All program

requirements

are met.

Program #4 The program is missing or does

not meet any of

the program

requirements.

Some program

requirements are

met.

Most program

requirements

are met.

All program

requirements

are met.

Program #5 The program is missing or does

not meet any of

the program

requirements.

Some program

requirements are

met.

Most program

requirements

are met.

All program

requirements

are met.