|
C++ |
|
Program |
Description |
|
BinToDec.cpp |
Write a program that converts a binary
number to decimal notation. Include a loop that lets the user
repeat this computation for new input values again and again
until the user says he or she wants to end the program. |
|
NumBack.cpp |
Write a program that allow to the
user enter a integer number as input and show the number in backwords
as output.Your program should include a loop that lets the user
repeat this calculation until the user says she or he is done. |
|
Nroot.cpp |
A method to calculate Q ^(1/n) is
the follow:
B
= ( (Q/A^(n-1)) + A*(n-1) )/ n
where:
Q
= Real number(+) to evaluate
n
= Integer(+)> 1
B
= result if B=A
Process:
a) Assum A=1
b) Calculate B
c) if A = B then the result will be B
Otherwise assign B to A and go to(b)
Note: use condition fabs(A-B)<0.001 |
|
PerfectCube.cpp |
Write a program to evaluate if a
integer number is a Perfect Cube or number of Armstrong ( Number
> 1 ).Your program should includea loop that lets the user
repeat this calculation until the user says she or he is done.
Note: if abc is perfect cube then
abc
= a^3 + b^3 + c^3
e.g.,
153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 |
|
PrimeFactors.cpp |
Write a program that allow to
the user calculates the prime factors of any number with its
powers(exponents).
Your program should include a loop that lets the user evaluate
other number again until theuser says he or she is done.
Example; Enter a number : 17424 //input
// Output in the screen should be:
Factor
Exponent
2
4
3
2
11
2
Do you want to continue ( Y/N) ? : _
Note: 17424 = (2^4) * (3^2) * (11^2)
Hint: use integer division ( / ) and % operator |
|
SumSeries.cpp |
Write a program to evaluate the following
sum:
1/3 + 1/15 + 1/35 +....+ 1/((2n-1)*(2n+1))
where 1/((2n-1)*(2n+1)) is the n-term of the expresion.
The program shoul take a limit value for the n-term as input
and output the sum. |
|
DigitRepetitions.cpp |
Write a program that will read in a long
integer number and will output how many times each digit is present
in the number.
Example, Input/Output:
Enter a number : 723345167
Digit #
of Repetitions
-----
----------------
1 1
2 1
3 2
4 1
5
1
6 1
7 2 |
|
GardenArea.cpp |
The area of a rectangular garden is
given by the expresion:
Area = X(30-2X) X belongs[2,12] X is integer
Write a program that show a table with the X values vs Area values
and also the program should output the maximun Area and the X
value for that maximun Area.
Example of Output:
X
Area
--- ------
2
52
3
72
4
88
.
..
.
..
.
..
12
72
Maximun Area = 112
X value for maximun Area = 7 |
|
RomanNum.cpp |
Write a program that accepts a integer
number greater than zero and less than 400 as a three-digit Arabic
(ordinary) numeral and outputs the number written in Roman numerals.Important
Roman numerals are: I for 1,
V for 5, X for 10, L for 50, C for 100. Recall that some numbers
are formed by using a kind of subtraction of one Roman digit;
e.g., IV is 4 produced as V minus I, XL is 40, XC is 90 etc.
Your program should include a loop that lets the user repeat
this calculation until the user says she or he is done. |
|
EvaluateFunction.cpp |
A) To write a program using subroutines
( procedures or functions ) to evaluate the following sum:
f(x) = 1 + x^2/2! + x^4/4! +...........+
x^(2*(n-1))/(2*(n-1))!
Allow to the user enters a specific
value for x and the number of terms to evaluate as inputs. The
program should output the sum.
Example ( for Output ):
Enter a x value: 2.5
Enter the number of terms to evaluate: 8
f(x) = 6.13
A.1) Try to solve the problem using
the regular structure:
Declaration part, main body, and implementation part
A.2) Try to solve the same problem using
a Header File |
| Pseudo.cpp |
In this project you will design and implement
a class that can generate a sequence of pseudorandom integers,
which is a sequence that appears random in many ways. The
approach uses the linear congruence method, explained below.The
linear congruence method starts with a number called the seed.
In addition to the seed,
three other numbers are used in the linear congruence method,
called the multiplier,the increment, and the modulus. The formula
for generting a sequence of pseudorandom
numbers is quite simple. The first number is:
(multiplier * seed + increment) % modulus
This formula uses the C++ % operator, which
computes the remainder from an integer division.
Each time a new random number is computed, the value of the seed
is changed to that new number.
For example, we could implement a pseudorandom number generator
with multiplier = 40,
increment = 3641, and modulus = 729. If we choose the seed to
be 1, then the sequence of numbers
will proceed as shown here:
First number
=(multiplier * seed + increment) % modulus
=(40 * 1 + 3641) % 729
=36
and 36 becomes the new seed
Next number
=(multiplier * seed + increment) % modulus
=(40 * 36 + 3641) % 729
=707
and 707 becomes the new seed
Next number
=(multiplier * seed + increment) % modulus
=(40 * 707 + 3641) % 729
=574
and 574 becomes the new seed, and so on
These particular values for multiplier,
increment, and modulus happen to be good
choices. The pattern generated will not repeat until 729 different
numbers have been
produced. Other choices for the constants might not be so good.
For this project, design and implement a class that can generate
a pseudorandom sequence
in the manner described. The initial seed, multiplier, increment,
and modulus should all
be parameters of the constructor. There should also be a member
function to permit the seed
to be changed, and a member function to generate and return the
next number in the
pseudorandom sequence.
|
| Quadratic.cpp |
A one-variable quadratic expression is
an arithmetic expression of the
form ax^2 + bx + c, where a,b, and c are some fixed numbers (called
the
coefficients) and x is a variable that can take on different values.
Specify,design, and implement a CLASS that can store information
about
a quadratic expression. The default constructor should set all
three
coefficient to zero, and another constructor should allow you
to
initialize these coefficients. There should be constant member
functions
to retrieve the current values of the coefficients. There should
also
be a member function to allow you to evaluate the quadratic expression
at a particular value of x (i.e., the function has one parameter
x ,
and returns the value of the expression ax^2 + bx + c ).
Also overload the following operators ( as nonmember functions)
to
perform these indicated operations:
Quadratic operator +( const Quadratic&
q1, const Quadratic& q2 );
// Postcondition: The return value is
the quadratic expression obtained
// by adding q1 and q2. For example, the c coefficient of the
return
// value is the sum of q1's c coefficient and q2's c coefficient.
Quadratic operator *( double r , const
Quadratic& q );
// Postcondition: The return value is
the quadratic expression obtained
// by multiplying each of q's coefficient by the number r.
Notice that the left argument of the overloaded
operator * is a double
number ( rather than a quadratic expression ). This allows expressions
such as 3.25 * q, where q is a quadratic expression.
In order to test your program you have
to build your own main body for
your program.
|
| TDpoint.cpp |
Specify,
design and implement a class that can be used to keep track of the
position of a point in three-dimensional space. For example, consider
the point
drawn here:
y-axis |
|
|
|
|
x-axis
.---------------------->
/
/
/
. ( 2.5, 0 ,2.0)
/
/
/
z-axis
The point shown above has three coordinates: x = 2.5, y = 0, and z =
2.0.
Include member functions to set a point to a specific location, to
shift a point
a given amount along one of the axes, and to retrieve the coordinates
of a point.
Also provide member functions that will rotate the point by a
specified angle
around a specied axis.
To compute these rotations, you will need a bit of trigonometry.
Suppose you have
a point with coordinates x,y,and z. After rotating this point by an
angle alpha,the
point will have new coordinates,which we'll call x',y', and z'. The
equation for
the new coordinates use the math.h library functions sin and cos, as
shown here:
After an alpha rotation around the x-axis:
x' = x
y' = y cos(alpha) - z sin(alpha)
z' = y sin(alpha) + z cos(alpha)
After an alpha rotation around the y-axis :
x' = x cos(alpha) + z sin(alpha)
y' = y
z' = -x sin(alpha) + z cos(alpha)
After an alpha rotation around the z-axis:
x' = x cos(alpha) - y sin(alpha)
y' = x sin(alpha) + y cos(alpha)
z' = z
Note: alpha is in radians
use this formula to convert degrees to radians
R = ( C * PI) / 180
where R : radians
C : degrees
PI : constant pi = 3.1415926.... |
|
|
|
|
|
|
|