Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

boolean expressions and testing in general L1 (0.2 marks) Code in the method lab1 in the DoingIt class of this weeks downloaded project. Using the

boolean expressions and testing in general

L1 (0.2 marks)

Code in the method lab1 in the DoingIt class of this weeks downloaded project.

Using the remainder operator (%) code and test a boolean expression that returns true if an integer variable n is a negative even number.

Design a set of test values and use these to test that your expression works as expected.

L2 (0.2 marks)

Code in the method lab2 in the DoingIt class of this weeks downloaded project.

Code and test a boolean expression that returns true if an integer variable n is in the range -30 to 150 inclusive but not an even in the range 80 to 90 inclusive.

Design a set of test values and use these to test that your expression works as expected.

L3 (0.4 marks)

Code in the method lab3 in the DoingIt class of this weeks downloaded project.

Code and test a boolean expression that returns true if a string variable userInput has any of the following values FIT, 1051, week.

Design a set of test values and use these to test that your expression works as expected.

L4 (0.4 marks)

Code in the method lab4 in the DoingIt class of this weeks downloaded project.

Code and test a boolean expression that returns false if a String variable userInput does not have the value FIT1051.

Design a set of test values and use these to test that your expression works as expected.

L5 (0.4 marks)

Code in the method lab5 in the DoingIt class of this weeks downloaded project.

The assignment operator allows you to assign the value of one variable to another variable but how can you swap the values in two variables?

Declare two boolean variables with initial values. Write additional code to swap these values. You must do the swap using variables (not literals).

L6 (0.4 marks)

Code in the method lab6 in the DoingIt class of this weeks downloaded project.

Write code to find the roots of the quadratic equation ax2 + bx + c = 0. The formula for the two roots is:

You can assume you will only have to deal with discriminants (b2 4ac) that are greater than or equal to zero i.e. no imaginary numbers.

Declare variables for a, b and c and set their values in their declaration. Declare as many other variables as you need. Dont try to do everything in a single statement, it just creates code that is difficult to understand and modify. Build the solution over several simple statements (e.g. discriminant, numerator, denominator) rather than a single complicated statement.

Do not perform calculations in a display statement such as myWindow.writeOutLine().

Finally, to prove that you understand operator precedence use the minimum number of parentheses in your calculation steps. Normally, of course, minimising the use of parentheses would be poor style. Why?

in java plz

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the purpose of having an organized sales process?

Answered: 1 week ago