logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Dawn WardManagement
(5/5)

815 Answers

Hire Me
expert
Marilyn DruetttEngineering
(5/5)

995 Answers

Hire Me
expert
Wayne FlynnManagement
(5/5)

887 Answers

Hire Me
expert
Joel FordFinance
(5/5)

575 Answers

Hire Me
C++ Programming

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.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

 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.  a) d != 5 || d != 6 || d != 7 || d != 8 || d != 9 || d != 10

                   1          2          3          4           5          6

Simple conditions ®                       

 

                   1)

 

                   2)

 

                   3)

 

                   4)

 

                   5)

 

                   6)

 

                   Compound condition value: __________

 

  1. b) e != 5 && e != 4 && e != 3 && e != 2 && e != 1 && e != 0

             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:

 

  1. a) Exclusive or (XOR)

 

“xor” operator truth table

Left side

Right side

Result

 

 

 

 

  1. b) Implication (®)

 

“implication” operator truth table

Left side

Right side

Result

 

 

 

 

  1. c) Biconditional («)

 

“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

 

  1. a) if statement version

 

 

 

 

  1. b) switch statement version

 

 

 

 

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?

 

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

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

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme