Sale!

# PRG 211 Week 2 Labs

\$ 9

977 in stock

Lab 5.1 Largest number

Write a program whose inputs are three integers, and whose output is the largest of the three values.

Ex: If the input is 7 15 3, the output is:
15

Lab 5.2 Remove gray from RGB

Summary: Given integer values for red, green, and blue, subtract the gray from each value.

Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color’s value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).

Given values for red, green, and blue, remove the gray part.

Ex: If the input is 130 50 130, the output is:
80 0 80
Find the smallest value, and then subtract it from all three values, thus removing the gray.

Lab 5.3 Leap Year

A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:

1. The year must be divisible by 4
2. If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400
Some example leap years are 1600, 1712, and 2016.

Write a program that takes in a year and determines whether that year is a leap year.

Ex: If the input is 1712, the output is:
1712 is a leap year.

Ex: If the input is 1913, the output is:
1913 is not a leap year.

SKU: PRG211WK2

## Description

Lab 5.1 Largest number

Write a program whose inputs are three integers, and whose output is the largest of the three values.

Ex: If the input is 7 15 3, the output is:
15

Lab 5.2 Remove gray from RGB

Summary: Given integer values for red, green, and blue, subtract the gray from each value.

Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color’s value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).

Given values for red, green, and blue, remove the gray part.

Ex: If the input is 130 50 130, the output is:
80 0 80
Find the smallest value, and then subtract it from all three values, thus removing the gray.

Lab 5.3 Leap Year

A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:

1. The year must be divisible by 4
2. If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400
Some example leap years are 1600, 1712, and 2016.

Write a program that takes in a year and determines whether that year is a leap year.

Ex: If the input is 1712, the output is:
1712 is a leap year.

Ex: If the input is 1913, the output is:
1913 is not a leap year.

## Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.