A student in Programming 1 wants to know the surface area and volume of a cylindrical shape.
Figure 5.1: Example of a cylinder
Volume = PI(R^²) x height
Area = 2PI(R^²) x height + 2PI(R^²)
5.1.1 Write a program that will assist the students:
5.1.2Create a C++ source file called Cylinder and save it in a file called Cylinder.cpp.
5.2 Create the following functions:
5.2.1 calcVolume() This function will receive three parameters and it must then calculate
and return the volume of a cylinder using the information given
above.
5.2.2 calcArea() This function will receive three parameters and it must then calculate
and return the area of a cylinder using the information given above.
5.2.3 main() NB: The functions must be implemented above the main.
Add all necessary pre-processor directives.
Declare all constants and necessary variables.
Prompt the user for the height of the cylinder, and the radius of
the base of the cylinder.
Based on the users option :
o Do the relevant calculations by calling the correct
function.
Display the results of the desired measurement.
If an invalid option is selected an appropriate error message
Fill in the blanks in the following program so that it draws the given picture. Each
figure is a rhombus with side 100 and interior angles (60, 120, 60, 120). The distance
between 2 adjacent rhombuses is 20 (between their closest vertices).
repeat(2){
repeat(2){
B1;
left(B3);
B1;
left(120);
}
right(120);
penUp();
B2;
penDown();
repeat(2){
B1;
left(120);
B1;
left(B3);
}
right(B3);
penUp();
B2;
penDown();
}
What is command B1?
forward(100)
forward(20)
backward(100)
backward(20)
What is command B2?
forward(100)
forward(20)
backward(100)
backward(20)
What is B3?
Fill in the blank in the following program that draws a figure resembling the letter 'Z' with sides (50, 100, 50) and the angle between them to be 60 degrees.
Remember that the turtle starts at the center of the canvas and facing right.
left(180); forward(50); right(B1); forward(B2); left(B3); forward(50);
What is B1?
What is B2?
What is B3?
Fill in the blanks to complete the code that prints the string:
“bccbccbccaaaaaaaaaabccbccbccaaaaaaaaaa”
repeat(B1){
repeat(B2){
cout<<"b";
repeat(B3){
cout<<"c";
}
}
repeat(B4){
cout<<"a";
repeat(2){
cout<<"a";
}
}
}
What is B1?
What is B2?
What is B3?
What is B4?
Fill in the blanks in the following program so that it draws the given picture. Each
figure is a rhombus with side 100 and interior angles (60, 120, 60, 120). The distance
between 2 adjacent rhombuses is 20 (between their closest vertices).
repeat(2){
repeat(2){
B1;
left(B3);
B1;
left(120);
}
right(120);
penUp();
B2;
penDown();
repeat(2){
B1;
left(120);
B1;
left(B3);
}
right(B3);
penUp();
B2;
penDown();
}
What is command B1?
forward(100)
forward(20)
backward(100)
backward(20)
What is command B2?
forward(100)
forward(20)
backward(100)
backward(20)
What is B3?
Suppose we have a 5 x 5 image.The pixels in the top row are numbered 0 through 4 left to right,the ones in the second row from the to are numbered 5 through 9 left to right, and so on. Suppose there is a 'T' in the middle. The horizontal bar is in the middle of the second row, and 3 pixels wide. The vertical bar is in the middle of the third column and is also 3 pixels wide. Only pixels of the 'T' are black, rest are white.
Suppose we flatten the image into an array(let's call it A, and it is indexed from 0) such that pixel number i goes into the array at index i. What is the index of a pixel in column a and row b? (Note that first row has a=0 and first column has b=0)
5 * j + i
5 * j * i
5 * i + j
5 * i + 5 * j
Which of the indices in the array correspond to black pixels ?
3
8
11
13
What is the total number of white pixels?
For the pixel at index i in the array, what are the corresponding row and column number (first row has row number 0, and second row has 1)?
Note: floor(x) is the largest integer that is less than or equal to x. ceil(x) is the smallest
integer that is greater than or equal to x.
floor(i/5), i%5
i%5, floor(i/5)
ceil(i/5), i%5
floor(i/5)+1, i%5
Create a new C++ program named “partA_q1.cpp”
Write a program in C++ to calculate and display the kinetic energy (J) of a 2.4 kg mass when the user provides its velocity (km/h). Use the following equation:
1 𝑘𝑖𝑛𝑒𝑡𝑖𝑐𝑒𝑛𝑒𝑟𝑔𝑦 =2×𝑚𝑎𝑠𝑠 ×(
Question 2
Create a new C++ program named “partA_q2.cpp”
𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 × 1000 2 60×60 )
Write a program in C++ that will let the user know whether a number that they enter is a multiple of eleven. Hint: If there is no remainder after dividing a number by eleven, that number is a multiple of eleven.
Question 3 [7 marks]
Create a new C++ program named “partA_q3.cpp”
Write another program that performs the same task as Question 2, but this program should allow the user to test another number, if they wish to do so.
(Hint: Modify your code from Question 2.)
Question 4 [15 marks] Create a new C++ program named “partA_q4.cpp”
Write a C++ program that uses a for() loop to calculate and display the sum of the following series, for a given the number of terms (n). n is to be provided by the user and must be greater than four.
𝑠𝑢𝑚𝑜𝑓𝑠𝑒𝑟𝑖𝑒𝑠= 1 + 1 + 1 +⋯+ 1
sin (1) sin (2) sin (3) sin (n) ππππ
[8 marks]
we know that the tabular computation of a dynamic- programming algorithm helps us to avoid recomputation. prove it using the example of fibonacci numbers.
· Case 1: Text categorization: Spam Detection.
· Case 2: Face detection.
· Case 3: Signature recognition.
· Case 4: Customer discover.
· Case 5: Medicine: Classify if a patient has heart ischemia by a spectral analysis of his/her ECG.
Find one (1) of the secondary datasets from the internet. Name the secondary dataset that you have found.
Mobile phones are considered to be the most common communication devices in history, mobile phones are not only used for casual greetings but also, sending and receiving important data such as, social security numbers, bank account details and passwords. Public key cryptography is a proven security solution, which can be used to secure the mobile communications. ABC company have been proposed; server-based framework public key cryptography solution to secure the mobile communications. Third party servers were used to check the certificates, authenticating the communicating parties, key distribution, etc. The proposed framework consists two type of ciphers; i) Public key Cryptosystem (RSA) and, ii) decrypt messages through the digital signature. There are four scenarios to be considered order security requirement of integrity and confidentiality; based on that scenarios answer the following questions:
a. Scenario 1: Show the security design and calculation steps for digital signature by figure and explain on how to calculate?
b. Scenario 2: Based on Scenario 1, show the security design sequences and calculation steps for one-way hash algorithm by figure and provide justification on the usage of one-way hash algorithm? Then, list the Properties of Hash Algorithm?
c. Scenario 3: Based on Scenario1, show the security design sequences and calculation steps for RSA by figure and explain how to use it to distribute the keys?
d. Scenario4: Based on Scenario 3, show the security design sequences and calculation steps for private key cipher by figure and explain how to use it for encrypt and decrypt messages?
what is the disadvantages and advantages of linked list
what is the disadvantages and advantages of array