PF Lab A3
PF Lab A3
PF-LAB
Program #01:
Create a program that reads a letter of the alphabet from the user. If the user enters a, e, i,
o or u then your program should display a message indicating that the entered letter is a vowel. If
the user enters y then your program should display a message indicating that sometimes y is a
vowel, and sometimes y is a consonant. Otherwise your program should display a message
indicating that the letter is a consonant.
C++ Code:
Output:
Program #02:
The length of a month varies from 28 to 31 days. Create a program that reads the name of a
month from the user as a string. Then your program should display the number of days in that month.
Display “28 or 29 days” for February.
C++ Code:
Output:
Program #03:
Write a program that reads a sound level in decibels from the user. If the user enters a
decibel level that matches one of the noises in the table then your program should display a
message containing only that noise. If the user enters a number of decibels between the noises
listed then your program should display a message indicating which noises the level is between.
Ensure that your program also generates reasonable output for a value smaller than the quietest
noise in the table, and for a value larger than the loudest noise in the table.
The following table lists the sound level in decibels for several common noises.
NOISE SOUND LEVEL
Jackhammer 130
Gas lawnmower 106
Alarm clock 70
Quiet room 40
C++ Code:
Output:
Program #04:
Canada has three national holidays which fall on the same dates each year. Write a program that reads a
month and day from the user. If the month and day match one of the holidays listed then your program
should display the holiday’s name. Otherwise, your program should indicate that the entered month and
day do not correspond to a fixed-date holiday.
HOLIDAY DATE
New year’s day January 1
Canada day July 1
Christmas day December 25
C++ Code:
Output:
Program #05:
Develop a program that reads a four-digit integer from the user and displays the sum of
the digits in the number. For example, if the user enters 3141 then your program should display
3+1+4+1=9.
C++ Code:
Output: