Professional Documents
Culture Documents
Take Home Exam (Gscomprog) By: Ma. Teresa Ramos-Abellera, ECE
Take Home Exam (Gscomprog) By: Ma. Teresa Ramos-Abellera, ECE
Take Home Exam (Gscomprog) By: Ma. Teresa Ramos-Abellera, ECE
FLOWCHART
START
IE = 0.0000
RE =0.0000
X[8]
k=0
X0 =0.0000
READ IE
X0 = IE
PRINT “ k#0”
k = k +1
YES
k<8 X[K] = (1.414)*(sinX[K-1])
NO RE = (X[k] - X[k-1])/(X[k])
STOP
A
1|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
PRINT
"k#"k
PRINT
" X "k “ = “X
PRINT
" Relative error = "RE
PROGRAM
#include <iostream.h>
#include<math.h>
int main()
X[k] = 0;}
cin>> IE;
X[0] = IE;
2|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
RE = (X[k] - X[k-1])/(X[k]);
} }
return 0;}
3|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
Program #2 (GSSTAT)
Problem #2: Cooking oils that are low in both cholesterol and saturated fats are often recommended for
people who are trying to lower their blood cholesterol level or to lose weight. Many cooking oils that have
no cholesterol still have saturated fat contents of 6% to 18%. Cooking oil made from soybeans has been
advertised as containing 15% saturated fats. A dietician thinks that the percentage of the saturated fats is
greater than15% and randomly selects 13 bottles of soybean cooking oil for testing. These bottles contain
the following percentages of saturated fats: 15.2, 12.4, 15.4, 13.5, 15.9, 17.1, 20.0, 16.9, 14.3, 19.1, 18.2,
15.5, and 16.316.9, 14.3, 19.1, 18.2, 15.5, and 16.3.
START
PercentSatFats[13] = {15.2, 12.4, 15.4, 13.5, 15.9, 17.1, 20.0,16.9, 14.3, 19.1, 18.2, 15.5,16.3}
total = 0.0
mean = 0.0
SumSqrM = 0.0
N=13
P = 15
SD = 0.0
t = 0.
df = 0.0
cv = 2.681
PRINT
" A. HYPOTHESIS "
PRINT
" Ho: P <= 15%"
PRINT
" Ho: P > 15%"
PRINT
" B. TEST STATISTICS "
4|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
PRINT
" t = ((Mean -P)/SD)x sqrtN "
df = N - 1
PRINT
" C. CRITICAL REGION "
PRINT
" Level of significance, a = 0.01"
PRINT
" Degree of freedom, df = "
PRINT
" (Please see table for the critical value.)"
PRINT
" Critical value, Z = " cv
PRINT
" D. DECISION RULE"
5|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
PRINT
" Computed value, tc < " cv " : Ho is not rejected."
" Computed value, tc => " cv " : Ho is rejected ."
C
x1 = x +1
x1<13
yes
D no
no mean = total/N
E x1<13
C
yes
6|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
PRINT
" Computed t = "t
PRINT
“Mean of the percentages of saturated fats = "mean
PRINT
" Number of samples, N = " N
PRINT
" Standard deviation, SD = " SD
PRINT
" D. DECISION AND CONCLUSION"
no
t < cv
F
yes
PRINT
omputed value t = " t " is less than the critical value = "cv",""therefore, Ho is rejected. The cooking oil made from soybeans contains 15% sat
G
STOP
7|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
PRINT
" Since the computed value t = " t " is greater than the critical value = "cv",""therefore, Ho
is not rejected. The cooking oil made from soybeans contains more tan 15% saturated
fats."
PROGRAM
//Cooking oils that are low in both cholesterol and saturated fats are often recommended
//for people who are trying to lower their blood cholesterol level or to lose weight. Many
//cooking oils that have no cholesterol still have saturated fat contents of 6% to 18%.
//Cooking oil made from soybeans has been advertised as containing 15% saturated fats.
//A dietician thinks that the percentage of the saturated fats is greater than 15% and
//randomly selects 13 bottles of soybean cooking oil for testing. These bottles contain
//the following percentages of saturated fats: 15.2, 12.4, 15.4, 13.5, 15.9, 17.1, 20.0,
//16.9, 14.3, 19.1, 18.2, 15.5, and 16.316.9, 14.3, 19.1, 18.2, 15.5, and 16.3.
#include <iostream.h>
#include <math.h>
int main()
{ float PercentSatFats[13] = {15.2, 12.4, 15.4, 13.5, 15.9, 17.1, 20.0,16.9, 14.3, 19.1, 18.2, 15.5,16.3};
float N=13;
float SD = 0.0;
float t = 0.0;
float df = 0.0;
8|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
float cv = 2.681; // cv = 2.681
df = N - 1;
mean = total/N;
9|Page
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
t = ((mean - P)/SD)* (pow (N, 0.5));
//Formulation of conclusion
if (t < cv)
{cout<<" Since the computed value t = "<<t<<" is less than the critical value =
"<<cv<<","<<"therefore, Ho is rejected. The cooking oil made from soybeans contains 15% saturated
fats."<<endl; }
else
{cout<<" Since the computed value t "<<t<<" is greater than the critical value
"<<cv<<","<<"therefore, Ho is not rejected. The cooking oil made from soybeans contains more than 15%
saturated fats."<<endl;}
return 0;}
10 | P a g e
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
Program #3 (GSNUMET)
FLOWCHART
START
IE = 0.0000
X [8]
FX =0.0000
FFX = 0.0000
RE = 0.0000
K1 =0
K2 =0
K1 = K + 1
K1<8 YES
X[K] = 0
NO
K2 = K2 +1
K2<=8
YES
A
NO
K2 = K2 +1
11 | P a g e
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
STOP
PROGRAM
#include <iostream.h>
#include<math.h>
int main()
double FX =0.0000 ;
X[k] = 0;}
cin>> IE;
X[0] = IE;
12 | P a g e
TAKE HOME EXAM (GSCOMPROG)
By: Ma. Teresa Ramos- Abellera, ECE
FFX = (cos(FX)) + (FX) - (0.52);
RE = abs(((X[k]) - (X[k-1]))/(X[k]));
return 0;}
13 | P a g e