You are on page 1of 13

A.

Problem 1

This program was designed to covert the angles from degrees to radians as well as to find their
respective sine and cosines of the angles.
INPUT
Degrees

PROCESSING
GET degrees
radians = degrees*pi/180
Calculate the sine of the
angle( radians)
Calculate the cosine of the
angle(radians)

OUTPUT
Degrees
Radians
Sine
Cosine

INPUT PROCESS OUTPUT CHART FOR PROBLEM 1

Pseudocode

GET degrees
INCREASE degrees by increments of 30
COMPUTE the angle in radians (rad) by dividing the product of the angle in degree and pi by 180
DETERMINE the sine of the angles in radians
DETERMINE the cosine of the angles in radians
DISPLAY Degrees, radians, sine and cosine.

Results

% This program generates a table of conversions from degrees to radians


% and calculates their respective sine and cosine functions
%
1

deg = 0:30:360;
rad = deg*pi/180;
a = sin(rad);
b = cos(rad);
%
table(:,1) = deg';
table(:,2) = rad';
table(:,3) = a';
table(:,4) = b';
%
disp(table)
0

1.0000

30.0000

0.5236

0.5000

0.8660

60.0000

1.0472

0.8660

0.5000

90.0000

1.5708

1.0000

0.0000

120.0000

2.0944

0.8660 -0.5000

150.0000

2.6180

0.5000 -0.8660

180.0000

3.1416

0.0000 -1.0000

210.0000

3.6652 -0.5000 -0.8660

240.0000

4.1888 -0.8660 -0.5000

270.0000

4.7124 -1.0000 -0.0000

300.0000

5.2360 -0.8660

0.5000

330.0000

5.7596 -0.5000

0.8660

360.0000

6.2832 -0.0000

1.0000

SCREENSHOT OF THE PROGRAM 1 BEFORE AND AFTER EXECUTION


2

Problem 2
This program was developed to determine the death of a creature utilizing the carbon 14 content for
that creature.

INPUT
Initial_amount of Carbon 14

PROCESSING
GET initial_ amount and
Remainder

OUTPUT

Remainder
CALCULATE n as equal to
(log
(remainder/initial_amount))
divided by (log (1/2));

PRINT USELESS

CALCULATE age as the


product of n and the half-life
of carbon 14 (5730)
IF n is more than one
THEN

INPUT PROCESS OUTPUT CHART FOR PROBLEM 2

Pseudocode

SET initial amount of carbon 14 to one hundred percent


PRINT Enter the percentage of the remaining carbon 14 from the creature
READ remainder
CALCULATE n as equal to (log (remainder/initial_amount)) divided by (log (1/2));
CALCULATE age as the product of n and the half-life of carbon 14 (5730)
4

IF

n is more than one

THEN

PRINT USELESS
ELSE
PRINT MATCH_FOUND
ENDIF

Results

>> % This program calculates the death of a creature.


%
initial_amount = 100;
remainder = input('Enter percentage of remaining carbon 14 on the : ');
n = (log(remainder/initial_amount)) / (log(1/2));
age = n*5730
%
if n > 1
fprintf('USELESS')
else
fprintf('MATCH_FOUND')
end
Enter percentage of remaining carbon 14: 60

age =

4.2228e+03
5

'MATCH_FOUND'>>

SCREENSHOT OF THE PROGRAM 2 BEFORE EXECUTION

SCREENSHOT OF THE PROGRAM 2 AFTER EXECUTION

Problem 3

This program was designed to determine the estimated number of years it would take for the population
of Jamhram City to surpass twenty million people and the citys estimated population at the end of this
time.
INPUT

PROCESSING
READ Population of Jamhram
city, Rate of the population
growth, Number of years

Population

Rate
Year

OUTPUT
The number of years for this
population to grow pass
twenty million.
Population of the city

while population < =


20000000 do
growth =
population*exp^(rate*year)
population = population +
growth
year = year + 1
Display year years required

INPUT PROCESS OUTPUT CHART FOR PROBLEM 3

PSEUDOCODE

SET Population equal to 50,000


SET rate equal to 0.00000000112
SET the year number of years equal to zero
WHILE the population is less than or equal to twenty million DO

Population is equal to the sum of the population and growth


Increment year
ENDWHILE
DISPLAY years required is , year
DISPLAY The population of the city is , population
END
9

RESULTS

>> %This program calculates the population growth of Jamhram city.


%
population = 50000;
rate = 0.000000001112;
year = 0;
%
while population <= 20000000
growth = population*exp(rate*year);
population = population + growth;
year = year + 1;
end
fprintf('%4.0f years required \n',year)
fprintf('%8.0f is the population of the city \n',population)
9 years required
25600001 is the population of the city

SCREENSHOT OF THE PROGRAM 2 BEFORE EXECUTION

10

SCREENSHOT OF THE PROGRAM 3 AFTER EXECUTION


11

12

13

You might also like