CSC242 Introduction to Programming Concepts Week Two Assignment First Name Last Name ID# Email Address Table of Contents How to submit your Assignment2 P1 – Geometry: Area of a Regular Polygon2 P2 –...

1 answer below »
Submit a copy of your code and a sample screenshot of the program output. Copy and paste all programs and outputs inonefile only. Do not submit separate files.
Acceptable formats are .doc and .docx. Only work submitted in document format will be graded.


CSC242 Introduction to Programming Concepts Week Two Assignment First Name Last Name ID# Email Address Table of Contents How to submit your Assignment2 P1 – Geometry: Area of a Regular Polygon2 P2 – Table of Squares and Cubes3 P3 – Diamond Printing Program3 P4 – Common Characters of two Strings4 P5 – Factorial5 P6 – Calculate e5 How to submit your Assignment After filling all the parts in this file, please follow the following steps. 1) Add your name and ID to the first page. 2) Save the file in the original format (Docx or Doc) (please do not convert to other file formats e.g. PDF, ZIP, RAR, …). 3) Rename the file as CSC242 – HW2 - ID – YOUR Last Name - YOUR First Name.docx Example: CSC242 – HW2 - 234566435 - Smith - John.docx 4) Upload the file and submit it (only using Blackboard) P1 – 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 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. Here is a sample run: Your C++ code for this problem -- Copy and paste your code here Run the code and insert the result in the following box. The run result Copy and paste the result here (e.g. the screenshot of the result you get by running the code). P2 – Table of Squares and Cubes Use the loops to write a program that calculates the squares and cubes of the numbers from 0 to 10 and prints the resulting values in table format, as shown below. Your C++ code for this problem -- Copy and paste your code here Run the code and insert the result in the following box. The run result Copy and paste the result here (e.g. the screenshot of the result you get by running the code). P3 – Diamond Printing Program Use the loops to write an application that prints the following diamond shape. Your C++ code for this problem -- Copy and paste your code here Run the code and insert the result in the following box. The run result Copy and paste the result here (e.g. the screenshot of the result you get by running the code). P4 – Common Characters of two Strings Write a program that prompts the user to enter two strings and then find the common characters of the two strings and displays them. Example: string1 = “Hello” string1 = “pilot” Common Characters = lo Your C++ code for this problem -- Copy and paste your code here Run the code and insert the result in the following box. The run result Copy and paste the result here (e.g. the screenshot of the result you get by running the code). P5 – Factorial The factorial of a nonnegative integer n is written as n! (pronounced “n factorial”) and is defined as follows: n! = n · (n – 1) · (n – 2) · … · 1 (for values of n greater than or equal to 1) and n! = 1 (for n = 0) For example, 5! = 5 * 4 * 3 * 2 * 1, which is 120. Write a program that reads a nonnegative integer and computes and prints its factorial. Your C++ code for this problem -- Copy and paste your code here Run the code and insert the result in the following box. The run result Copy and paste the result here (e.g. the screenshot of the result you get by running the code). P6 – Calculate e Use the factorial program in the previous problem and extend it to write a program that estimates the value of the mathematical constant e by using the following formula. Allow the user to enter the number of terms to calculate. Your C++ code for this problem -- Copy and paste your code here Run the code and insert the result in the following box. The run result Copy and paste the result here (e.g. the screenshot of the result you get by running the code). The end
Answered Same DayApr 15, 2021

Answer To: CSC242 Introduction to Programming Concepts Week Two Assignment First Name Last Name ID# Email...

Kshitij answered on Apr 15 2021
150 Votes
CSC242 Introduction to Programming Concepts Week Two Assignment
    First Name
    
    Last Name
    
    ID#
    
    Email Address
    
Table of Contents
How to submit your Assignment    2
P1 – Geometry: Area of a Regular Po
lygon    2
P2 – Table of Squares and Cubes    3
P3 – Diamond Printing Program    3
P4 – Common Characters of two Strings    4
P5 – Factorial    5
P6 – Calculate e    5
How to submit your Assignment
After filling all the parts in this file, please follow the following steps.
1) Add your name and ID to the first page.
2) Save the file in the original format (Docx or Doc)
(please do not convert to other file formats e.g. PDF, ZIP, RAR, …).
3) Rename the file as
CSC242 – HW2 - ID – YOUR Last Name - YOUR First Name.docx
Example: CSC242 – HW2 - 234566435 - Smith - John.docx
4) Upload the file and submit it (only using Blackboard)
P1 – 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
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. Here is a sample run:
    Your C++ code for this problem
    -- Copy and paste your code here
# include
# include
# include
# include
using namespace std;
float roundValue(float var)
{
float value = (int)(var * 100 + .5);
return (float)value / 100;
}
int main() {
float n;
float s;
cout<<"Enter the number of sides :";
cin>>n;
cout<<"Enter the side :";
cin>>s;
float ans= (n*s*s)/(4*tan(22/(7*n)));
cout<<"The area of the polygon is "< return 0;
}
Run the code and insert the result in the following box.
    The run result
    Copy and paste the result here (e.g. the screenshot of the result you get by running the code).
P2 – Table of Squares and Cubes
Use the loops to write a program that calculates the squares and cubes of...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here