Question 1

(Geometry: area of a regular polygon)

A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is

area = (n * s^2) / (4 * tan(PI / n)

Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area.

Sample Run

Enter the number of sides: 5
Enter the side: 6.5
The area of the polygon is 72.69017017488385

Question 2

(Convert letter grade to number)

Write a program that prompts the user to enter a letter grade A/a, B/b, C/c, D/d, or F/f and displays its corresponding numeric value 4, 3, 2, 1, or 0.

Sample Run 1

Enter a letter grade: B
The numeric value for grade B is 3

Sample Run 2

Enter a letter grade: b
The numeric value for grade b is 3

Sample Run 3

Enter a letter grade: T
T is an invalid grade

Question 3

(Days of a month)

Write a program that prompts the user to enter the year and the first three letters of a month name (with the first letter in uppercase) and displays the number of days in the month.

Sample Run 1

Enter a year: 2001
Enter a month: Jan
Jan 2001 has 31 days

Sample Run 2

Enter a year: 2000
Enter a month: Feb
Feb 2000 has 29 days

Sample Run 3

Enter a month: 2001
Enter a month: jan
jan is not a correct month name

Question 4

(Business: check ISBN-10)

An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. The last digit, d10, is a checksum, which is calculated from the other nine digits using the following formula:

(d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) % 11

If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros).

Sample Run 1

Enter the first 9 digits of an ISBN as a string: 3601267
Incorrect input. It must have exact 9 digits

Sample Run 2

Enter the first 9 digits of an ISBN as a string: 013601267
The ISBN-10 number is 0136012671

Sample Run 3

Enter the first 9 digits of an ISBN as a string: 013031997
The ISBN-10 number is 013031997X

Question 5

(Hex to binary)

Write a program that prompts the user to enter a hex digit and displays its corresponding binary number.

Sample Run 1

Enter a hex digit: B
The binary value is 1011

Sample Run 2

Enter a hex digit: b
The binary value is 1011

Sample Run 3

Enter a hex digit: T
Invalid input
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.