We want to calculate the total
marks of each student of a class
in Physics, Chemistry and
Mathematics and the average
marks of the class. The number
of students in the class are
entered by the user. Create a
class named Marks with data
members for roll number, name
and marks. Create three other
classes inheriting the Marks
class, namely Physics, Chemistry
and Mathematics, which are
used to define marks in
individual subject of each
student.
Write a C++ program to calculate relativistic kinetic energy (K), when the mass (m) is given by the user. The given below is the equation to calculate the relativistic kinetic energy.
m = mass, v = 1500 ms-1 (speed of the moving object), and c = 12000 ms-1(speed of light)
Sample Output
Enter a mass of the moving objects (m): 60
60 8.7083e+09
59 8.56316e+09
58 8.41802e+09
57 8.27289e+09
56 8.12775e+09
. A right triangle can have sides whose lengths are all integers. The set of three integer
values for the lengths of the sides of a right triangle is called a Pythagorean triple.
The lengths of the three sides must satisfy the relationship that the sum of the squares
of two of the sides is equal to the square of the hypotenuse. Write an application that
displays a table of the Pythagorean triples for side1, side2 and the hypotenuse, all no
larger than 500. Use a triple-nested for loop that tries all possibilities. This method is
an example of “brute-force” computing. You’ll learn in more advanced computer
science courses that for many interesting problems there’s no known algorithmic
approach other than using sheer brute force.
Write a C++ program called onlineB.cpp to calculate horizontal range of the projectile motion (R) when a baseball player throws a ball at a speed of 30 ms-1 and the angle (in degrees) is given by the user. The given below is the equation to calculate the horizontal range of the projectile motion.
v = 30.0 (speed of the throwing), g = 9.8 (gravity), and θ = angle in radians
Sample Output
Write a program that prints the result of rolling one fair
dice.
Hint: use the rand() function with range given in
arguments to generate a random integer in the desired
range.
Add a loop to print the sum of rolling 10 fair dice.
Add a second loop to repeat this N times, printing the
sum after each trial.
Maintain an array count[] so that count[k] stores the
number of times the sum is exactly k.
Review your code and eliminate glitches and unnecessary
repetitions if any
Write c++ code to display avarage of all the element of array (hint [I] =4*I+1 and size of array=5)
Write a program which has a class called String containing a character array as a data member. The class should contain constructor for input and an appropriate member function for throwing an exception in case the ASCII value of a character is prime. You may use any other data members or member functions you deem necessary for computing the answer
Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.
Input 1:-
I am 25 years and 10 months old
Output 1:-
35
17.5
Input 2:-
Tech Foundation 35567
Output 2:-
35567
35567.0
Input 3:-
Anjali25 is python4 Expert
Output 3:-
29
14.5
We want given both three inputs they can get both three outputs we code was run one by one input and output
Write a program which has an abstract class called Number having an integer data member. The class contains a pure virtual function called operation. A class called odd is derived from class called Number. Another class called Even is derived from class Number. Yet another class called prime is derived from Number. Use appropriate constructors and redefine the function called operation to display if the number is odd, even or prime. You may make use of other data members and member functions if needed
Compare the methods of determining prime numbers with code and concept.
i.Naive method
ii.square root method
iii.Seive of Eratosthenes