lab assigments
1. W
ite a program
that inputs FRO
M
THE U
SER the values of three Boolean variables
cin
operator from
the eight Possible cases used in the previous dem
o w
hich are in the text Table 3.2
2. Since the user gives the values be sure to prom
pt O
R IN
STRU
CT THE U
SER, W
HAT THIS PRO
GRAM
IS ALL
ABO
U
T W
HAT THEY W
ILL N
EED TO
GIVE AN
D W
HAT THEY W
ILL GET.).
3. O
nce values are in the program
determ
ines the Boolean logical value of the conditions that follow
as true or
false.
!( A&
&
B&
&
!C) and ( A||B) &
&
C
4. O
utput should include the values of a,b,c
ie
0 or 1 in patterns that include the values com
ined w
ith strings and an
appropriate string variable as follow
ing exam
ple of one case.
input of a=1 and b =0 and c=1 results in output looking like
!( 1&
&
0&
&
0) is True
(1||0)&
&
1 is True
For exam
ple, if the condition w
as a sim
ple a&
&
and a=1 and b=0 then the output w
ould look like 1&
&
0 is False the
com
puter line doing this w
ould be cout
Fbanana
endl;
W
here the string variables Tbanana
and Fbanana
w
ere set equal to true and false.
W
hich one cam
e out depended on an if statem
ent testing the condition a&
&
just before output
5. Run for the eight cases of a,b,c
in Table 3.2 (both editions of text) also as in previous dem
o.
Additional Hint: your output statem
ents w
ill be large! and you have to use strings and variables
etc
study last dem
o also on how
to do it.
6. REM
EM
BER A G
O
O
D ABSTRACT
AN
D
LA
B
#6 exam
ple, N
ote due date from
class,, Em
ail subject G#-lab6
W
ite a C++ program
to calculate the SW
EAT IN
DEX(SW
I) know
n as the severe w
eather threat index, that predicts severity
types of thunderstorm
s that are possible. The SW
I form
ula depends on the tem
perature in degrees(T) Fahrenheit (50 to 100
ange) and the Radar m
easured low
er atm
osphere w
ind velocity(W
) (50 TO
120 range).
W
ith a given tem
perature(T) and w
ind Velocity(W
) the SW
I w
ill predict thunderstorm
activity.
1. U
se the Follow
ing form
ula. SW
I =150log(T-49)+0.1W
+125W
T
2. Prom
pt the user w
ith inform
ation w
hat this program
is all about for the required input of T and W
.
3. If the index value of SW
I is below
295 then report N
on-severe thunderstorm
s are possible,If the index value is
295 to 385 report severe thunderstorm
s are possible And if it is >385 report Severe thunderstorm
s, including
tornados are likely.
4. note: use only one nested
IF/else structures to cover the 3 cases
not 3
HIN
T: see play com
puter exam
ple in the lecture FO
R THE DESIGN
.
5 .Find by trial and e
or input data in there range above to Run for each of the three possible outcom
es. O
utput
all values,SW
I ,T&
W
and an appropriate report statem
ent!
6. Run one hand check for the value of T for one of your inputs of T and W
.
show
results on program
7. D
o a flow
chart and send in w
ith the program
: D
esign in w
ord w
hich has M
ost Flow
chart sym
ols in
8.REM
EM
BER A GO
O
D ABSTRACT
AN
D
PRO
GRAM
LAB #7 N
ote due date from
class,, Em
ail subject G
#-lab7
lab 4 and 5
LAB 4 TEM
PLATE
GENERAL OVERALL PRO
GRAM
STRUCTURE-O
RGANIZATIO
N
1. A
stract
for the program
m
er, w
hat this is all about, form
ulas used in alge
aic form
2.Includes section
Necessary li
aries to run program
2. m
ain()
int m
ain() { starts solution line com
m
ents
that clarify are used liberally below
3.D
eclaration section. Typesof variables are defined, som
etim
es initialized.
descriptive nam
es for num
erical variables and string variables useful for units
4. Inputsection if needed
uses coutcom
m
ands to explain program
for user, w
hat it is all about, w
hat they need to enter and w
hat they w
ill get.
uses cin
com
m
and to get values from
use
5. calculations section
form
ulas that do the calculations need to solve the problem
s
6.output section
uses cout
for values solved along w
ith descriptive inform
ation to understand w
hat is com
ing out of the program
The charge hits the negative plate at a velocity v,falling in a tim
e t. H
itting w
ith kinectic
energy, K
.
Equations governing the behavior are
F=Q
E a =F/m
y=1/2at 2 v=at K
=1/2 m
v
2
The charge Q
= 4.1 X 10
-6C
oulom
s and the electric field E
is 6.84 X 10
7 N
ew
tons/C
oulom
. The
m
ass m
of the charged particle is 1.4 x 10
-6kg, considered a constantin this case, define in the
co
ect place in the program
(before m
ain), and the separation of the plates Y
= 0.54 m
eters.
1. A
B
STR
A
C
T:
PR
O
G
R
AM
M
ER
/*)w
ith your nam
e ,date and LAB
#4 at start!
2. C
O
M
M
EN
TS:
B
e sure there are creative
com
m
ents to yourself. A
ll over.
3. U
SER
PR
O
M
TS: descriptive output using cout, like cout
). U
ser needs to know
w
hat it is all
about and w
hat to give and w
hat they w
ill get! In IN
P
U
T section
C
ontinued next slide +- +
LA
B
#4 carefully U
SE G
U
ID
E B
ELO
W
requirem
ents A
N
D
use last tem
plate m
odel structure.. N
ote due
date from
class, Em
ail subject G
#-lab4.Feel Free to H
elp others but do not give your code!
GIVEN Electrodynam
ic situation. Tw
o charged plates on the left,
separated by a distance Y
(m
eters), create an electric field, E,
w
hich is m
easured as the force per unit charge
(New
tons/Coulom
). A sm
all positive charged particle, Q
,
(Coulom
s) is placed at the top plate and experiences a force, F
(New
tons), w
hich creates an acceleration, a
(m
s 2), tow
ards
negative, it travels the full distance Y.
4. D
E
S
C
R
IP
TIV
E
N
A
M
E
S
for variables not physics a
eviations as above.
Exam
ple, double Force, Voltage, etc
in D
EC
LAR
ATIO
N
SEC
TIO
N
5. U
SER
IN
PU
T:
A
FTE
R
E
XP
LA
IN
IN
G
TH
E
A
LL, E
N
TE
R
S
TH
E
C
u
ent values of
cin
and input in scientific notation (e) and
form
ulas calculate the rest like. IN
IN
P
U
T S
E
C
TIO
N
-C
A
LC
U
LATIO
N
S
FO
LLO
W
!
6.FIR
ST SO
LU
TIO
N
: Your program
solves forthe force, F, and acceleration, a.
7.
N
EXT C
ALC
U
LATIO
N
: From
the third equation, y=1/2at 2 you need the tim
e, t,
setup solution as an equation A
nd have the com
puter solve it FO
R
t=
8.
N
EXT C
ALC
U
LATIO
N
:Then solutions for v
since t is know
n and then K
9. U
S
E
e scientific notation for all.
10.. U
se string variables to hold all the units and output them
w
ith calculated values.
11. B
e sure to use follow
ing m
ath functions: pow
() , sqrt() eg. pow
(x,3) sam
e as
x
3
12. O
utput w
ith description and scientific
setw
()
and seprecison(4)
13.. H
and C
alculation on the lab exercise to check com
puter logic, add at end.
14. R
E-R
EAD
ALL IN
STR
U
C
TIO
N
S B
EFO
R
E H
A
N
D
IN
G
IN
TO
B
E SU
R
E A
LL D
O
N
E.