Programming Assignment Help: Example

Given an integer representing a 7-digit phone number, excluding the area code, output the prefix and line number, separated by a hyphen.

Ex: If the input is 5551212, the output is:

555-1212

Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2 digits of 572 is gotten by 572 % 100, which is 72.

Hint: Use / to shift right by the desired amount. Ex: Shifting 572 right by 2 digits is done by 572 / 100, which yields 5. (Recall integer division discards the fraction).

For simplicity, assume any part starts with a non-zero digit. So 011-9999 is not allowed.

2. 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.

3. On a piano, each key has a frequency, and each subsequent key (black or white) is a known amount higher. Ex: The A key above the middle C key has a frequency of 440 Hz. Each subsequent key (black or white) has a frequency of 440 * r^n, where n is the number of keys from that A key, and r is 2^(1/12). Given an initial frequency, output that frequency and the next 4 higher key frequencies.

Ex: If the input is 440, the output is:

440.0 466.1637615180899 493.8833012561241 523.2511306011974 554.3652619537442

Note: Include one statement to compute r = 2^(1/12) using the RaiseToPower() function, then use r in the formula fn = f0 * r^n. (You’ll have four statements using that formula, different only in the value for n).

 
Do you need a similar assignment done for you from scratch? Order now!
Use Discount Code "Newclient" for a 15% Discount!