Question

4. Construct a logical expression to represent each of the following conditions: a. chris either B, or ‘b b. x is even but not 30 c. y is in the range 3000-4500 or z is 5. d. x being a value between, but not including, 500 and 650, or y not equal to 1000. x being a value less than or equal to 500 or greater than 650, and y not equal to 1000. e. (20 points) 5. Write C++ statements that output Democrat if the party affiliation code (party_code) is D, Republican if the party affiliation code is R, and independent otherwise. (use switch control structure.) (21 points)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

4

a. chr=='B'||chr=='b'

b. x%2==0&&x!=30

c. (y>=3000&&y<=4500)||z==5

d. (x>500&&x<650)||y!=1000

e. (x>500&&x<650)&&y!=1000

5.

switch(party_code)

{

case 'D':

cout<<"Democrat\n";

break;

case 'R':

cout<<"Republican\n";

break;

default:

cout<<"independent\n";

}

Add a comment
Know the answer?
Add Answer to:
4. Construct a logical expression to represent each of the following conditions: a. chris either 'B,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Construct an C expression to express the following conditions: Example: a is between 1 and 100....

    Construct an C expression to express the following conditions: Example: a is between 1 and 100. Answer: a>=1 && a<=100 1) x is equal to or greater than 90 but smaller than 100 2) y is not between 40 and 60

  • QUESTION 1 What will be displayed as a result of executing the following code? int   x...

    QUESTION 1 What will be displayed as a result of executing the following code? int   x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points    QUESTION 2 What will be the displayed when the following code...

  • Please answer and explain thank you. Question 1 What will be printed when the following code...

    Please answer and explain thank you. Question 1 What will be printed when the following code is executed? double x = 45678.259; System.out.printf("%,.2f", x); Group of answer choices 45678.259 0,045,678.26 45,678.26 45,678.3 Question 2 What will be printed when the following code is executed? double x = 45678.259; String output = String.format("%,.1f", x); System.out.println(output); Group of answer choices 45678.259 45,678.259 45,678.26 45,678.3 Question 3 What will be the value of ans after the following code has been executed? int ans=0;...

  • D Question 1 3 pts Construct an C expression to express the following conditions: Example: a...

    D Question 1 3 pts Construct an C expression to express the following conditions: Example: a is between 1 and 100. Answer: a" 1 && a<-100 1) x is equal to or greater than 90 but smaller than 100 2) y is not between 40 and 60 3) z is between 20 and 30 but not equal to 25 HTML Editoru

  • For 1 through 11, create an expression using the relational operators, the logical operators, and variable...

    For 1 through 11, create an expression using the relational operators, the logical operators, and variable names of your own choosing, no if or variable declaration is necessary. 1. is a person's age equal to 30? 2. is a body temperature greater than 98.6? 3. is a person's height less than 6 feet? 4. is the current month 12? 5. check if the letter input is m 6. is a person's age equal to 30 and is the person taller...

  • Kelang e. 2 IUUIS, J9 Ulules, 15 Selurus. Question Completion Status: QUESTION 6 4 points Save...

    Kelang e. 2 IUUIS, J9 Ulules, 15 Selurus. Question Completion Status: QUESTION 6 4 points Save Answer For which of the following scenarios would an Analysis of Variance (ANOVA) be appropriate? Determining if the distribution of party affiliation (Democrat, Republican, Independent) has changed since the last election Determining if the proportion of the population that are left handed is more than 10% Determining whether Income Level (Low, Middle, High) and Credit Score (Poor, Fair, Good, Excellent) are independent Determining if...

  • Question 10 (3 points) Which of the following statement is not true? There is a recursive...

    Question 10 (3 points) Which of the following statement is not true? There is a recursive sum method as shown below. When sum (19) is called, summation of all odd numbers less than 19 will be calculated and returned public int sum(int x){ if (x == 0) return 0: else return sum(x-2) + x; The following code segment will throw a testException. This exception has been handled in the way that do nothing but to continue when this exception happens....

  • Q3. i) [2] Implement the following Boolean expression using basic gates. [(A + B) (C+DJE +...

    Q3. i) [2] Implement the following Boolean expression using basic gates. [(A + B) (C+DJE + FG 121 ii) Using K-Map deduce the value of each function W,X,Y,Z Table.3A X Y Z А 0 0 B 0 0 с 0 W 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 - 1 0 0 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 0 1 1...

  • QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

    QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points    QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...

  • 3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa...

    3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT