Do not use any if statements! Rule 1: If I see a friend, I greet them. (Friends can be seen more than once in the same input.) Rule 2: If a person doesn't have the name of a friend, I do not greet them. Rule 3: The input consists of the names of the people I meet represented as String data. Note: All output should be true if and only if a certain condition occurs. Your code must return true for all situations where that condition occurs, not just some of them. Similarly, your code must return false for all situations where the condition does not occur. For example, if I have two friends named "Abby" and "George", I would greet both of them if I saw "Abby" first, then "George". But, I would also greet them both if I saw "George" first, then "Abby". My code would need to print true in both of those situations, not just one of them. Friend: "Karen" Input: 2 people Output: true iff I greet Karen twice. (false otherwise) boolean once=input() == "Karen" boolean twice = input() == "Karen" print twice AND NOT once print input() == "Karen" print input() == "Karen" string person1=input() boolean friend friend = (person1 == "Karen" AND person1 == "Karen") print friend string person1 =input() string person2 = input() boolean friend friend (person1 == "Karen" AND person2 == "Karen") print friend

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please provide answer accurately and I include multiple choices as well. 

Do not use any if statements!
Rule 1: If I see a friend, I greet them. (Friends can be seen more than once in the same
input.)
Rule 2: If a person doesn't have the name of a friend, I do not greet them.
Rule 3: The input consists of the names of the people I meet represented as String
data
Note: All output should be true if and only if a certain condition occurs. Your code must
return true for all situations where that condition occurs, not just some of them. Similarly,
your code must return false for all situations where the condition does not occur.
For example, if I have two friends named "Abby" and "George", I would greet both of
them if I saw "Abby" first, then "George". But, I would also greet them both if I saw
"George" first, then "Abby". My code would need to print true in both of those situations,
not just one of them.
Friend: "Karen"
Input: 2 people
Output: true iff I greet Karen twice.
(false otherwise)
boolean once = input() == "Karen"
boolean twice = input() == "Karen"
print twice AND NOT once
print input() == "Karen"
print input() == "Karen"
string person1 = input()
boolean friend
friend = (person1 == "Karen" AND
person1 == "Karen")
print friend
string person1 = input()
string person2 = input()
boolean friend
friend = (person1 == "Karen" AND
person2 == "Karen")
print friend
Transcribed Image Text:Do not use any if statements! Rule 1: If I see a friend, I greet them. (Friends can be seen more than once in the same input.) Rule 2: If a person doesn't have the name of a friend, I do not greet them. Rule 3: The input consists of the names of the people I meet represented as String data Note: All output should be true if and only if a certain condition occurs. Your code must return true for all situations where that condition occurs, not just some of them. Similarly, your code must return false for all situations where the condition does not occur. For example, if I have two friends named "Abby" and "George", I would greet both of them if I saw "Abby" first, then "George". But, I would also greet them both if I saw "George" first, then "Abby". My code would need to print true in both of those situations, not just one of them. Friend: "Karen" Input: 2 people Output: true iff I greet Karen twice. (false otherwise) boolean once = input() == "Karen" boolean twice = input() == "Karen" print twice AND NOT once print input() == "Karen" print input() == "Karen" string person1 = input() boolean friend friend = (person1 == "Karen" AND person1 == "Karen") print friend string person1 = input() string person2 = input() boolean friend friend = (person1 == "Karen" AND person2 == "Karen") print friend
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY