GE1103 Engineering Design
CP-1
Cornerstone
1
CP-1
AMINO ACIDS, POWER OF 2, INTEGER MATH
LAB OBJECTIVES
In this lab, you will:
• Prepare a flowchart to plan your approach to solving the given problem(s).
• Calculate the molecular weight of an amino acid.
• Write a C++ program to calculate the power of 2.
• Write a program to understand the limitations of integer mathematics.
• Create a memo addressed to the Professor describing the results for problem #1 (the total
weights and average weight per atom of the requested amino acids) AND Problems 2 and 3, in
order. Each problem describes what is required to be included in the lab package (on paper).
The screen shots should be referenced in the text but included as appendices to your memo.
• Submit: All cpp files, and a pdf with your: memo with screenshots and the flow chart in it.
Pre-Lab
Prepare a flowchart for Problem #1. This is to be word-processed, flowchart with symbols and
co
ect shapes. Be sure to include all steps for the user input, calculations and the console output.
Submit with Lab #1.
1. Problem #1
As you may have learned in Chemistry, the amino acids in proteins are composed of atoms of
oxygen (O), ca
on (C), nitrogen (N), sulfur (S) and hydrogen (H), as shown in the table below.
Table 1. Amino acid “recipes”.
CP-1
Cornerstone
2
The molecular weights of an atom of the individual elements are as follows:
The molecular weight of each acid can be computed by multiplying the number of atoms of each
substance times the weight of each atom.
Example: Alanine
The weight of a molecule of Alanine is:
(2)* XXXXXXXXXX)* XXXXXXXXXX)* XXXXXXXXXX)* XXXXXXXXXX)* XXXXXXXXXX) = XXXXXXXXXXu.
The average atomic weight of Alanine is 89.094/ XXXXXXXXXX) = 6.853 u.
Task for Problem #1:
Write a C++ program that asks the user (via the keyboard) to enter the number of atoms of each of the
elements for an amino acid. The program should then compute the molecular weight for this amino acid
and the average weight per atom and print out these values (use data type ‘double’).
The printout values should be in fixed format, using 3 decimal precision.
You should then use the program to compute the molecular weight and average weight per atom for the
following acids and include the results in your memo:
1) Cysteine 2) Glycine 3) Methionine
Include screenshots of the console inputs & outputs (I/O) for each of the three amino acid calculations in
your submission package.
(unit is u, which
is ‘atomic mass
unit’)
Table 2. Molecular weights by atom type.
CP-1
Cornerstone
3
2. Problem #2
Write a C++ program to display the powers of 2.
Display in columns and rows up to 28.
Use a ‘for’ loop in the program to count from
0 to 8.
Use the pow(x,y) function.
You will need the math li
ary: #include
cmath>.
pow(x,y) uses doubles as inputs and returns a
double as output.
Include a screenshot of the console output for the
powers of two in your submission package.
3. Problem #3
Identify each e
or & fix in the following C++ program:
#include
int main ()
{ int X, Y;
cout
“Enter X: ”; cin
X;
cout
“Enter Y: ”; cin
Y;
Z = X/Y;
cout
“X/Y=“
Z;
cout
“End of program.” endl;
eturn 0;
Enter the code and make the program run
co
ectly.
Test Case: the co
ect results for X=16.5 and
Y=2.2
Include a screenshot of the console output for the
test case shown above in your submission
package.
Your output may look like:
Enter X: 16.5
Enter Y: 2.2
X/Y=7.5
End of program.
Press any key to continue
CP-1
Cornerstone
4
Ru
ic:
Item Comments Points
Flowchart Done on computer (draw.io or other), co
ect shapes and
logical progression 15
Organization: Entire report should be in the proper sequence.
( Memo: Problems 1-3 in order and labeled screen shots) 10
Memo Memo to Prof/TA with molecular weights and average
atomic weights for 3 amino acids. Summarize results from
problems 2 and 3 and upload your file as:
LastName_CP1_Memo.pdf
10
Problem #1
Code:
• Program written as requested by the assignment.
• Commented with clear comments that help the user
understand the logic of this code
• First comments contain student’s name and date.
• Formatted appropriately (indentations/parentheses)
10
Canvas upload of program: LastName_CP1_1.cpp 5
Screen capture of the Console Window – 3 amino acids 10
Problem #2
Code:
• Program written as requested by the assignment.
• Commented with clear comments that help the user
understand the logic of this code
• First comments contain student’s name and date.
• Formatted appropriately (indentations/parentheses)
10
Canvas upload of program: LastName_CP1_2.cpp 5
Screen capture of the Console Window 5
Problem #3
Code:
• Program written as requested by the assignment.
• Commented with clear comments that help the user
understand the logic of this code
• First comments contain student’s name and date.
• Formatted appropriately (indentations/parentheses)
10
Canvas upload of program: LastName_CP1_3.cpp 5
Screen capture of the Console Window 5
TOTAL 100
Cornerstone
SF-1
SF-1 – Pedestrian Crossing Signal
Create a board that makes car traffic light (red, yellow and green LEDs) and pedestrian light (RGB LED)
along with a push button, to request access to cross the road. The board must behave as follows:
1. Start with the programming of a traffic light (TL):
a. General Rules:
i. Green lights are on for 5 seconds
ii. Yellow on for 2.5 sec.
iii. Red on for 7.5 seconds
. Ge this to work first before moving on
2. Modify your code such that, as soon as the car TL turns red, a pedestrian light (PL) cycle begins:
a. General Rules:
i. PL turns white (3 sec cross time)
ii. Then turns orange1 and blinks (for 2 sec total, 0.25 delay between each blink)
iii. Then turns solid orange and stays orange (for 2.5s).
. Get this to work before you move on
3. Modify your code to allow access to the road add push button to your circuit.
a. General Rules:
i. Push button will be ignored if the TL is yellow or red.
ii. When the button is pushed (LOW), the car traffic light should turn yellow (for 2.5
sec), then red (7.5 secs).
iii. As soon as the car TL turns red, the pedestrian light turns white (3 sec cross time),
then turns orange and blinks (for 2 sec, 0.25 delay), then turns solid orange and stays
orange until the next red light, at which point the PL’s cycle resets.
iv. Repeat.
Tips for success
• Use the flat jump wires when possible to create a cleaner design
• You will need to use the codes provided to you from Sparkfun to create new code to run this
program. All the attributes discussed above MUST function in one code file. Copy and Pasting
from the Sparkfun code is acceptable for this assignment.
• Use constant variables to store pin numbers, push button state, etc.
• Your name and email address should be in the first line.
• Your code should have enough comments to help me understand:
- What each line of your code does, and how the hardware is connected
• Prepare a final wire diagram of the components used for this assignment using AutoDesk
circuit/CAD program!
1 The standard pedestrian signals specified by the US Department of Transportation Federal Highway
Administration are a White walking person and a "Portland Orange" Stop Hand (not red). These colors were chosen
so as to be conspicuous against a backdrop of red, green and yellow lights at intersections and to avoid giving
drivers false cues of a green light (a good example of a resilient design).
Cornerstone
SF-1
Submission:
• Please