The template code provided is intended to take two inputs, x and y, from the user and print "pass" if one or more of the following is true:
x is not less than 4
y is not greater than 5 and x + y is less than 7
However, when using De Morgan's law to simplify this code, the programmer has made some mistakes. Can you correct the errors so the code functions as intended?
/* Lesson 6 Coding Activity Question 2 */
import java.util.Scanner;
public class U3_L6_Activity_Two{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
int y = scan.nextInt();
if(!((x 5) || x+y > 7))
System.out.println("pass");
}
}

Answers

Answer 1

import java.util.Scanner;

public class U3_L6_Activity_Two{

   public static void main(String[] args){

       Scanner scan = new Scanner(System.in);

       int x = scan.nextInt();

       int y = scan.nextInt();

       if(x>=4|| ((y < 5) && ((x+y) < 7))){

           System.out.println("pass");

       }

   }

}

I'm pretty sure this is what you're looking for. Best of luck.

Answer 2

For formatting and readability sake, the given code is re-written as follows:

/* Lesson 6 Coding Activity Question 2 */

import java.util.Scanner;        // 1

public class U3_L6_Activity_Two{ // 2

   public static void main(String[] args){     // 3

      Scanner scan = new Scanner(System.in);   // 4

      int x = scan.nextInt();     // 5

      int y = scan.nextInt();    // 6

      if(!((x 5) || x+y > 7))         // 7

      System.out.println("pass");    // 8

    }

}

The line that needs to be fixed is the if statement in line 7.

As given in the instruction, the code prints "pass" if one or more of the following is true:

i. x is not less than 4. This can be re-written as;

 ! ( x < 4 )

ii. y is not greater than 5 and x + y is less than 7. This can be re-written as;

! (y > 5) && (x + y < 7)

To have the right operand of ii to have a negation, we can re-write as follows;

! (y > 5) && ! (x + y > 7)  (i.e changing the less than sign to greater than and then putting the negation sign (!)). This is great so that the De Morgan's law will be applicable on both sides.

Note:

a. ! is the Java's equivalent way of writing the logical operator NOT

b. && is the Java's equivalent way of writing the logical operator  AND

Since one or more of the conditions in (i) and (ii) need to be true before the "pass" is printed, we can combine (i) and (ii) using the OR operator ( || ) as follows;

! ( x < 4 )  ||  ( ! (y > 5) && ! (x + y > 7) )           ----------------(***)

The De Morgan's laws are very great for making deductions, equivalence and valid proofs when using logical operators.

The laws are as follows;

i. ∼ (P ∧ Q) = ∼ P ∨ ∼ Q

This can be written as;

! (P AND Q) = ! P OR !Q

or in Java like syntax as

! (P && Q) = ! P || !Q

ii. ∼ (P ∨ Q) = ∼ P ∧ ∼ Q

This can be written as;

! (P OR Q) = ! P AND !Q

or in Java like syntax as

! (P || Q) = ! P && !Q

Using these laws, we can simplify our expression in (***) as follows;

! ( x < 4 )  ||  ( ! (y > 5) &&  ! (x + y > 7) )

a. Start with the right side i.e ( ! (y > 5) && ! (x + y > 7) )

The De Morgan's law (stated in (ii) above) will remove the negation from both terms in the right side term, change the && to || and then put a single negation to apply to both terms in the bracket to give the following;

! ( x < 4 )  ||  ! ( y > 5  || x + y > 7 )

b. Now, there are two main terms - ! ( x < 4 ) and ! ( y > 5  || x + y > 7 ) separated by ||

Apply the De Morgan's law (stated in (i) above) to remove the negation from both terms, then change the || to && and then put a single negation to apply to both terms.

! ( x < 4  && (y > 5  || x + y > 7))

The result in b is the simplified version of the condition in the if statement.

The complete and corrected code is therefore written as follows;

/* Lesson 6 Coding Activity Question 2 */

import java.util.Scanner;        // 1

public class U3_L6_Activity_Two{ // 2

   public static void main(String[] args){     // 3

      Scanner scan = new Scanner(System.in);   // 4

      int x = scan.nextInt();     // 5

      int y = scan.nextInt();    // 6

      if(! ( x < 4  && (y > 5 || x + y > 7) ) )         // 7

      System.out.println("pass");    // 8

    }

}

Read more about De Morgan's law at: https://brainly.com/question/13317840


Related Questions

Style guides advise writers on which issues? Check all that apply.

applying consistent standards
citing sources
formatting text
performing research
using correct definitions

Answers

Answer:

A. applying consistent standards

B. citing sources

C. formatting text

Explanation:

A style guide can be defined as a set of standards that typically guides writers or authors in writing and the design of documents such as memo, novels, books etc, for a particular organization, specific publications or general use by the public such as students, academic scholars or institutions, government, careers, businesses etc.

Basically, a style guide avails the writers or authors with the sets of standards so as to ensure uniformity in formatting techniques, style and citations.

Hence, style guides advise writers on issues such as;

I. Applying consistent standards.

II. Citing sources.

III. Formatting text.

Answer:

ABC

Explanation:

Learning Task 5. Identify the terms being described below. Write your answer in your answer
sheet.
1. This refers to the collection, transportation, processing or disposal, managing and
monitoring of waste materials.
2. This refers to the hazard control which involves the measure of replacing one hazardous
agent or work process with less dangerous one.
3. A very important method of controlling hazards which involves proper washing of your hair,
skin, body and even your clothes.
4. This refers to the preparedness for the first and immediate response in case of any type of
emergency.
5. This hazard control refers to the removal of a specific hazard or hazardous work process.
6. What is the term used to call the range of concentration over which a flammable vapor
mixed with air will flash or explode if an ignition is present?
7. A cross-disciplinary area concerned with protecting the safety, health and welfare of people
engaged in work or employment.
8. The term used in hazard control which involves changing a piece of machinery or work
process.
9. The term used to call any piece of equipment which is used to protect the different parts of
the body such as ears and eyes such as respirators, face mask, face shield, gloves, boots,
etcetera.
10. This is a form of hazard control which involves manipulation of worker/employee’s schedule
and job rotation.

Answers

Answer:

1. Waste management.

2. Substitution.

3. Personal hygiene practices.

4. Emergency preparedness.

5. Elimination.

6. Flammability limit.

7. Occupational safety and health (OSH).

8. Engineering controls.

9. Personal protective equipment (PPE).

10. Administrative controls.

Explanation:

1. Waste management: this refers to the collection, transportation, processing or disposal, managing and monitoring of waste materials.

2. Substitution: this refers to the hazard control which involves the measure of replacing one hazardous agent or work process with less dangerous one.

3. Personal hygiene practices: a very important method of controlling hazards which involves proper washing of your hair, skin, body and even your clothes.

4. Emergency preparedness: this refers to the preparedness for the first and immediate response in case of any type of emergency.

5. Elimination: this hazard control refers to the removal of a specific hazard or hazardous work process.

6. Flammability limit: is the term used to call the range of concentration over which a flammable vapor mixed with air will flash or explode if an ignition is present.

7. Occupational safety and health (OSH): a cross-disciplinary area concerned with protecting the safety, health and welfare of people engaged in work or employment.

8. Engineering controls: the term used in hazard control which involves changing a piece of machinery or work process.

9. Personal protective equipment (PPE): the term used to call any piece of equipment which is used to protect the different parts of the body such as ears and eyes such as respirators, face mask, face shield, gloves, boots, etcetera.

10. Administrative controls: this is a form of hazard control which involves manipulation of worker/employee’s schedule and job rotation.

Choose the correct term to complete the sentence.

is often used to describe the scope of a variable that is only accessible within a function.

Neighborhood

Local

Functional

Answers

Answer:

Answer is Local

Explanation:

Answer:

Local

Explanation:

Edge 2020

can anyone answer this ​

Answers

Answer:

I dont see the question

Explanation:

The interprets the data while it is in RAM​

Answers

Answer:

The input interprets the data while it is in RAM.

Explanation:

This is used to track a user’s browser and download history with the intent to display popup banner ads that will lure a user into making a purchase.

Select one:
Adware
Worm
Phishing
Malware

Answers

Answer:

Adware

Explanation:

Adware is software designed to display advertisements on your screen, most often within a web browser.

Hope that helps.

A software that used to track a user’s web browser and download history with the intent to display popup banner adverts (ads) that will lure an end user into making a purchase is: A. Adware.

An adware is also referred to as an advertisement-supported software and it can be defined as a software application (program) that is designed and developed to automatically display advertising materials such as banners or pop-up adverts (ads) on the graphical user-interface (GUI) of a user's computer system or mobile device.

The main purpose for the development of an adware is to automatically display popup banner adverts (ads), in order to lure or convince an end user into making purchase of the advertised product or service.

In conclusion, an adware is a software that is typically used to track and gather information about a user’s web browser and download history with the intent to display popup banner adverts (ads) that will lure an end user into making a purchase.

Read more on adware here: https://brainly.com/question/9692296

WHAT DOES INFORMATION TECHNOLOGY DO??
Do they offer services or products

Answers

Yes

Explanation: Information technology, or IT, describes any technology that powers or enables the storage, processing and information flow within an organization. Anything involved with computers, software, networks, intranets, Web sites, servers, databases and telecommunications falls under the IT umbrella.

Python Project Worksheet
Print | Save
Output: Your goal
You will write a program that asks a user to fill in a story. Store each response in a variable, then print the story based on the responses.

Part 1: Plan and Write the Pseudocode
Use the following guidelines to write your pseudocode for a fill-in story program.

Decide on a list of items the program will ask the user to input.
Your program should include at least four interactive prompts.
Input from the user should be assigned to variables and used in the story.
Use concatenation to join strings together in the story.
Print the story for the user to read.


Write your pseudocode here:











Part 2: Code the Program
Use the following guidelines to code your program.

Use the Python IDLE to write your program.
Using comments, type a heading that includes your name, today’s date, and a short description.
Set up your def main(): statement. (Don’t forget the parentheses and colon.)
Conclude the program with the main() statement.
Include at least two print statements and two variables.
Include at least four input prompts.
Use concatenation to join strings.
Follow the Python style conventions regarding indentation in your program.
Run your program to ensure it is working properly. Fix any errors you may observe.
Example of expected output: The output below is an example of a “Favorite Animal” message. Your specific results will vary depending on the choices you make about your message.

Output

The kangaroo is the cutest of all. It has 5 toes and a beautiful heart. It loves to eat chips and salsa, although it will eat pretty much anything. It lives in New York, and you must be super sweet to it, or you may end up as its meal!


When you've completed writing your program code, save your work by selecting 'Save' in the Python IDLE. When you submit your assignment, you will attach this Python file separately.

Part 3: Post Mortem Review (PMR)
Using complete sentences, respond to all the questions in the PMR chart.

Review Question Response
What was the purpose of your program?
How could your program be useful in the real world?
What is a problem you ran into, and how did you fix it?
Describe one thing you would do differently the next time you write a program.

Part 4: Save Your Work
Don't forget to save this worksheet. You will submit it for your assessment.

Print | Save

Answers

Answer:

I will do it and send it in a pic

Explanation:

give me a sec

Complete the sentence

-------- are technologies support virtual communities and the sharing of content with friends and family.

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is: Online community technologies.

So, we can fill this question with the correct option as below:

Online community technologies are technologies that support virtual communities and the sharing of content with friends and family.

As we know that online community technologies are those technologies where people of the same group or interest make community virtually online. Where they can share their contents such as pictures, videos, thaught, ideas, etc with the group or family members.

There are different technologies that support virtual communities to share content with friends and family.

Such as Zoom meetings, Sk ype, Face book, Insta gram etc.

Answer:

Taking the quiz rn and I put social media

Explanation:

Social media is the closest description to this however it may be collaborative tools if it’s not social media.

define reading and writing that regards storage​

Answers

Answer:

Reading and writing on computers and other gadgets require storage.

HOPE THIS HELPS

HAPPY THANKSGIVING

Who here would like to play among us with me?
Time: Friday, November 13

Answers

Answer:

sure

Explanation:

Assignment 4: Evens and Odds

Answers

n = int(input("How many numbers do you need to check? "))

even = 0

odd = 0

for x in range(n):

   num = int(input("Enter number: "))

   if num % 2 == 0:

       print(str(num) + " is an even number.")

       even += 1

   else:

       print(str(num) + " is an odd number.")

       odd += 1

print("You entered "+str(even)+" even number(s).")

print("You entered "+str(odd)+" odd number(s).")

This works for me. Best of luck.

The program checks if user supplied integers are even or odd and displays the appropriate value. The program is written thus in python 3 ;

n_check = int(input("How many numbers do you need to check? "))

#number of values user wishes to test

even_count = 0

odd_counts = 0

for n in range(n_check):

num = int(input("Enter number: "))

if num % 2 == 0:

#even numbers leave no remainder when divided by 2

print(str(num) + " is an even number.")

even_counts+= 1

#increase count of even numbers

else:

print(str(num) + " is an odd number.")

odd_counts += 1

print("You entered "+str(even_counts)+" even number(s).")

print("You entered "+str(odd_counts)+" odd number(s).")

#display the number of even and odd numbers entered.

Learn more : https://brainly.com/question/24171161

The Monroe Doctrine promised that the United States would:
A. not accept new colonies in the Americas.
B. cut itself off from nearly all foreign trade.
C. send its military to defend all new democracies.
D. take a more active role in European affairs.​

Answers

Answer:A

Explanation:

The Monroe Doctrine promised that the United States would not accept new colonies in the Americas. The correct option is A.

What is Monroe Doctrine?

The Monroe Doctrine is the most well-known example of US policy toward the Western Hemisphere.

The doctrine, buried in President James Monroe's routine annual message to Congress in December 1823, warns European nations that the United States will not tolerate further colonization or puppet monarchs.

Although initially ignored by Europe's great powers, the Monroe Doctrine eventually became a cornerstone of US foreign policy.

President James Monroe of the United States declared the United States to be the protector of the Western Hemisphere in 1823, prohibiting European powers from colonizing additional territories in the Americas.

The doctrine's three main concepts separate spheres of influence for the Americas and Europe, non-colonization, and non-intervention were intended to mark a clear break between the New World and Europe's autocratic realm.

Thus, the correct option is A.

For more details regarding Monroe Doctrine, visit:

https://brainly.com/question/290388

#SPJ5

What must you consider when determining the efficiency of an algorithm? Select two choices.

Answers

Answer:

C. The number of characters used to write the program

And

D. The length of time required to run the program

Explanation:

Hope this helped

Advantages of Linux include_____.
(Multiple choice)(photo attached)

-cost
-the ability to tweak the application
-ease of use
-security
-a time table for customer support

Answers

Answer:

The ability to tweak an application, and i think security. I've barely scratched the surface of linux so my answer may not be 100% accurate

Explanation:

4.5 code practice edhesive

Answers

Answer:

n= input("Please enter the next word: ")

x=1

while(n != "STOP"):

 print("#" + str(x) + ": You entered " + n)

  x=x+1

  n= input("Please enter the next word: ")

print("All done. " + str(x-1) + " words entered.")

Explanation:

PLEASE HELP Due Today

Match the term with one of its characteristics.

1. Automation software that enables servers to be provisioned automatically or with a few clicks of a mouse.

2. Log managers read your system logs and look for patterns and make reports.

3. Created an elastic infrastructure that expanded and contracted as demand changed.

cloud

maintain security

data center​

Answers

The matchup are:

1. Created an elastic infrastructure that expanded and contracted as demand changed -cloud2. Log managers read your system logs and look for patterns and make reports.- Maintain security 3. Automation software that enables servers to be provisioned automatically or with a few clicks of a mouse-data center​

What is the software  about?

The  Cloud computing is one that gives a form of elastic infrastructure that gives room for on-demand allocation as well as deallocation of resources.

Lastly  Log managers are known to be computer tools that tends to read system logs as well as look for patterns in the data to see security threats.

Learn more about software   from

https://brainly.com/question/28224061

#SPJ1

what messages do we get about ourselves from rap and hip hop

Answers

The lyrics let us know that we have reached a very low point in the music industry

you need to listen to some YEEEE YEEEEE music

HELP ME ASAP
Fred is using an enterprise system to create a database solution for his office. What would be the advantage of using an enterprise system?

Enterprise systems are single processor systems that do not take up many resources. However, they can be pipelined over multiple processors to lesson the computation time. Enterprise solutions provide a single database to simplify operation. These systems are faster and provide data redundancy.

Answers

Answer:

Enterprise solutions provide a single database to simplify operation

Explanation:


1. As part of your community, your school, and your neighbourhood, how else does ICT have an impact on social
awareness? What are these changes that are neglected in the bigger perspective?

Answers

Answer:

helthcare systems, aviation, entertainment, retail, etc

Explanation:

ICT has made life easy, it has made an interconection accross the world. in the helthcare system, ICT has created a positive impact because now a days body check up is been made through computers.

in the aviation, we use computers to control the the traffic of airplanes.

Select the correct answer from the drop-down menu.
Chrissie shirks the additional work given to her.
She lacks the trait of

Answers

Answer:

Responsibility

Explanation:

I need help please I’m behind

Answers

Answer:

The last one

Explanation:

Software is coding so they'll be impressed :)

Answer:

network administrator

Explanation:

It says a job that manages NETWORK hardware and software. So I would put network administrator.

When numbers are changed in cells that are involved in formulas, the formulas are automatically
changed
highlighted
O removed
recalculated

Answers

When numbers are changed in cells that are involved in formulas, the formulas are automatically
changed
highlighted
O removed
recalculated
removed

I think it is O removed

Why do digital media professionals create portfolios of their work?

Answers

Answer:

Then you're going to have to create a digital media portfolio in order to showcase your technical skills and knowledge. It can act as your online resume. You can use it to showcase your related work and projects to potential employers and clients online.

Explanation:

Direction: Put a check (/)mark if the statement is
correct and Irofessional. Letter W if it is incorrect.

Answers

Explanation:

Xghhdghxhdhzhhzshh, hdhshxxx

Choose the parts of the browser window. PLEASE ANSWER QUICKLY TEST

Answers

it would be display window

Answer:

display window

Explanation:

as it is where the browsed data is to be displayed

Hi! Is anyone really good at making pretty schedules and designs? I don't have any money, but I could give points. I'll give a small number of points on this answer, but if you make the schedule I'll give you lots of points! (I'll send you the actual parts of the schedule I just need someone to make it look pretty) Thank you so much!

Answers

Could I see what you would like it to look like?

i emailed someone and im sure that they emailed back however it says nothing has arrived in my inbox what do I do

Answers

Answer:

report it or check ur spam mail or refresh the page

Explanation:

good luck figuring it out :)

Complete the sentence

. A single IP address ______ be simultaneously assigned to more than one device in the network.

Answers

Answer:

Cannot, I will just stick with that answer. if not that it's can.

<BUTTON TYPE="BUTTON" VALUE="SUBMIT">SUBMIT YOUR FORM</BUTTON>
</FORM>
</BODY>
</HTML>
Write the question of this programming .​

Answers

Answer:

The correct answer to this question is given below in the explanation section.

Explanation:

This is an inference question. I mean that in this question, an answer is given, you have to generate the question.

The given code is :

BUTTON TYPE="BUTTON" VALUE="SUBMIT">SUBMIT YOUR FORM</BUTTON>

</FORM>

</BODY>

</HTML>

So, the answer (i.e. to write a question) is

Write a HTML code that displays a button in its body with the text "Submit Your Form ".

Other Questions
Start by clearly defining your topic with a thesis statement.Remember, your statement should be concise and precise. Anyone know this one? Choose the verb(s) in this sentence. Aluminum storm windows with painted finishes are slightly more expensive than those with natural finish Write the missing number and name the property(733X5)2= 733 x 5 Approximately 18% of the population of California is 70 years or older. In a random sample of 4, what is the provability for 3 of these people to be older than 70 years old.\ Whats the combined average of Altuves weighted average below:Friday 3 for 5, Saturday 2 for 4, and Sunday 1 for 3 The length of a rectangle is represented by 4 + 6x. The width is half the length. What expression represents the perimeter of the rectangle? Explain your reasoning choose the verb(s) in this sentence. Aluminum storm windows with painted finishes are slightly more expensive than those with natural finish Who is the most powerful undertale character Which statement below is most representative of Stephen Douglas opinion concerning slavery in states new to the Union?Group of answer choicesIt is the duty of Congress to protect the rights of slave owners to the property (slaves) in all states.The status of slavery in the new states should be determined by a vote of the people.Slavery should be outlawed in the lands acquired from Mexico.The Missouri Compromise is the legal way to decide the slavery question. please help will give brianliest PLEASE HELPExplain what is happening at this step in the solving equation process.10 6 x = 4 + 5 x7-6x=1+5x3 ( 4 x 3 ) = 154x-3=55x/-3=12/15x=-363 ( 4 x 3 ) = 154x-3=5 If g (x) = 3x 2, find g (8) g(-5) HELP ASAP!!! WILL GIVE BRAINLIEST TO FIRST WITH A GOOD ANSWER! Samir usually drink 3 cups of coffee in the morning how many liters of coffee does he drink round whos the queen?ariana grandems.ponytailms.butera(i was bored lol) On a double-well roller coaster, the person starts from a height of 10.5 meters, the height of the middle bump of the well is 6.7 meters. How much kinetic energy does this person have at the middle of the middle bump from the bottom if the mass of the person is 79 kg? (g=9.8 m/s2) Round to two decimal places. Utopia by Thomas More: What constitutes a new life in Utopia versus reality? Which city did King David make the royal capital of the Kingdom of Israel?CanaanJerusalemPhilistineCairo Why did the United States want more land after acquiring Texas