Question

In: Computer Science

Model 2 Relational Operators In Model 1, you determined the top three attributes by comparing percentages....

Model 2 Relational Operators

In Model 1, you determined the top three attributes by comparing percentages. We can declare variables to represent these percentages in Java:

double written = 82.0; // Communication skills (written)

double problem = 80.9; // Problem-solving skills

double teamwork = 78.7; // Ability to work in a team

In the table below, predict the result of each expression and identify the operator (if any). The first three rows are completed for you.

Expression Result Operator

written

82.0 none
written > problem true >
problem < teamwork false <
82.0 < written
82.0 > written
82.0 == written
problem == written
teamwork == problem
teamwork = problem
teamwork == problem
problem
teamwork

5. A relational operator compares two values; the result is either true or false. Identify the three relational operators used in the table above.

6. Explain why the same expression teamwork == problem resulted with two different values in the table.

7. What is the difference between = and == in Java?

8. The != relational operator means “not equals”. Give an example of a boolean expression that uses != and evaluates to false.

9. The >= relational operator means “greater than or equal to”. Give an example of a boolean expression that uses >= and evaluates to true.

10. Java has six relational operators. Only five have been mentioned, but you should be able to guess the sixth. List all six below, and explain briefly what each one means.

Solutions

Expert Solution

Expression               Result       Operator
----------               ------       --------
written                   82.0       none
written > problem       true       >
problem < teamwork       false       <
82.0 < written           false       <  
82.0 > written           false       >
82.0 == written           true       ==
problem == written       false       ==
teamwork == problem       false       ==
teamwork = problem       80.9       assignment, not a relational operator
teamwork == problem       true       ==
problem                   80.9       none
teamwork               80.9       none

5. The relational operators are ==, > and <

6. The assignment expression, teamwork = problem, makes the value of teamwork same as problem; hence the same logical expression, teamwork == problem has different values before and after the assignment operation.

7. The = is an assignment operation, assigning the value from the right hand side to the variable on the left hand side. The == is a relational operator comparing two values for equality.

8. teamwork != problem is the required expression; it evaluates to false because both are equal to 80.9.

9. written >= problem is a boolean expression that evaluates to true.

10. The relational operators are:
==    equals
!=    not equals
>    greater than
<   less than
<=    less than or equal to
>=    greater than or equal to


Related Solutions

tableA is a table in a relational database with a composite prime key. You have determined...
tableA is a table in a relational database with a composite prime key. You have determined that the table is 2NF. Owing to the fact that it is 2NF and the key is composite, is it automatically 3NF? Explain your answer. (4 points) Lack of normalization of database tables may cause update, delete, and/or insert anomalies. You have a 2NF table, tableA, in a relational database. Give an example of an anomaly to which tableA might still be subject. Give...
Case:Starbucks 1、Use VRIO model to do the internal analysis; 2、If you were the top management of...
Case:Starbucks 1、Use VRIO model to do the internal analysis; 2、If you were the top management of Starbucks, how to attain sustainable competetive advantage.
Think of the following linear attributes model. There are three goods, x, y and z, available...
Think of the following linear attributes model. There are three goods, x, y and z, available at prices px=3, py=2 and pz=4.A consumer cares about attributes a1 and a2 and one unit of good x has a1x=3 units of a1 and a2x=2 units of a2. For good y and z, suppose a1y=6, a2y=1 and a1z=4, a2z=3. Suppose the consumer has the initial wealth (income)w=12. We assume the consumer will spend all her wealth. (a)If the consumer wants to consume (a1,a2)=(16,8),...
5. A Company is comparing three alternative investments in Field 1, Field 2 and Field 3....
5. A Company is comparing three alternative investments in Field 1, Field 2 and Field 3. This company opts to undertake the analysis using a discount rate of 10%. The estimated cash flows for each investment are as follow: Years Field 1 Cash Flow $ Field 2 Cash Flow $ Field 3 Cash Flow $ 0 -75,000 -175,000 -475,000 1 30,000 25,000 150,000 2 20,000 25,000 150,000 3 20,000 25,000 150,000 4 15,000 25,000 75,000 5 10,000 25,000 75,000 6...
In the past two weeks you have learned about the relational data model and hopefully had...
In the past two weeks you have learned about the relational data model and hopefully had some practice creating a normalized relational schema through the use of entity/relationship modeling. Based on what you know, please think about various types of software application. Consider what the databases that back these applications might look like. Describe at least one application--whether already existing or hypothetical--for which you believe the relational model would NOT be a good fit. Explain why. Describe another application--already existing...
(JAVA) 1.) Create a class called Rabbit that with 2 attributes: 1) speed and 2) color....
(JAVA) 1.) Create a class called Rabbit that with 2 attributes: 1) speed and 2) color. Then, create a constructor that has no parameters, setting the default speed to 0 and the color to “white”; this is called a default constructor. Next, create a second constructor that takes in two parameters. The second constructor should assign those parameters to the attributes. Then, in main, create two Rabbit objects. For the first Rabbit object, call the first constructor. For the second...
Project [2]: Expressions and Operators Project Goals The goal of this project is to: 1. Get...
Project [2]: Expressions and Operators Project Goals The goal of this project is to: 1. Get students familiar with expressions and operators. Important Notes: 1. Formatting: Make sure that you follow the precise recommendations for the output content and formatting. For example, do not change the text from “You’re walking through the woods and come upon a chest. Do you open it? 1 – yes 2 - no” to “Do you open the chest? ”. Your assignment will be auto-graded...
1.Explain the Two-Factor model by Merton. 2.Explain the Fama-French Three-Factor Model.
1.Explain the Two-Factor model by Merton. 2.Explain the Fama-French Three-Factor Model.
Task 2 (1 mark) Transformation of data stored in the relational tables into data stored in...
Task 2 (1 mark) Transformation of data stored in the relational tables into data stored in BSON collection.
23 You are comparing two water softeners. One is an inexpensive model by a large conglomerate...
23 You are comparing two water softeners. One is an inexpensive model by a large conglomerate (GB) and the other is a deluxe model manufactured by a specialized water treatment company (Kin). The GB costs $800 and the Kin costs $2,395. There are two advantages to the Kin: first, it is mechanical with no electronics, so its expected life is 12 years; second, it is extremely efficient in its use of water and salt. The Kin’s estimated annual operating cost...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT