Problem Solving and Programming
1) [4 points] Given the variable declarations, evaluate the following compound conditions. Indicate with YES or NO next to each of the six numbers whether that simple condition will be evaluated. Also, indicate the value of the compound condition.
int d = 7;
int e = 2;
1 2 3 4 5 6
Simple conditions ®
1)
2)
3)
4)
5)
6)
Compound condition value: __________
1 2 3 4 5 6
Simple conditions ®
1)
2)
3)
4)
5)
6)
Compound condition value: __________
2) [3 points] The most common logical operators are AND, OR, and NOT, but there are other ones. Research and complete truth tables for the following operators:
“xor” operator truth table |
||
Left side |
Right side |
Result |
|
|
|
“implication” operator truth table |
||
Left side |
Right side |
Result |
|
|
|
“biconditional” operator truth table |
||
Left side |
Right side |
Result |
|
|
|
3) [6 points] Prompt for and read a single upper-case element symbol into char variable sym. Print the corresponding element and atomic number. Print an error message if any other character is entered. Write both if statement and switch statement versions.
Element |
Symbol |
Atomic number |
Boron |
B |
5 |
Carbon |
C |
6 |
Nitrogen |
N |
7 |
Oxygen |
O |
8 |
4) [4 points] Write a validation loop that prompts for and gets from the user a string that is at least five characters in length. If the string is outside that length range, print a message including the string and prompt the user again. Declare string variable str to hold the string. Allow the user to enter spaces.
5) [7 points] Write the number of for statement loops that will be performed for each of the following:
|
Initialization |
Condition |
Update |
Loops? |
a) |
i = -4 |
i <= 4 |
i = i + 1 |
|
b) |
i = 20 |
i < 30 |
i = i + 4 |
|
c) |
i = 7 |
i <= 7 |
i = i – 1 |
|
d) |
i = 15 |
i > 16 |
i = i * 2 |
|
e) |
i = 0 |
i < 50 |
i = i – 3 |
|
f) |
i = 24 |
i > 12 |
i = i – 2 |
|
g) |
i = 17 |
i != 8 |
i = i – 2 |
|
6) [1 point] Why should the continue statement rarely be used?
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme