1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Scilla [17]
3 years ago
13

What is wrong, logically, with the following code?if (x > 10) System.out.println("Large");else if (x > 6 && x <

= 10) System.out.println("Medium");else if (x > 3 && x <= 6) System.out.println("Small");else System.out.println("Very small");
A) There is no logical error, but there is no need to have (x <= 10) in the second conditional or (x <= 6) in the third conditional
B) There is no logical error, but there is no need to have (x > 6) in the second conditional or (x > 3) in the third conditional
C) The logical error is that no matter what value x is, "Very small" is always printed out
D) The logical error is that no matter what value x is, "Large" is always printed out
Computers and Technology
1 answer:
musickatia [10]3 years ago
5 0

Answer:

Option A is the correct answer for the above question.

Explanation:

  • The above code checks the value of the x and print ("Large" for the value of 'x' which is greater than '10'), ("medium" for the value of x which is smaller than or equal to 10 and greater than 6), ("small" for the value of 'x' which is smaller than or equal to 6 and greater than 3) and ("Very small" for the value of 'x' which is less than or equal to 3.
  • The if-else statement has the property that if the if condition is false then it goes on the else statement or else-if statement.
  • The above code firstly checks for the if statement, then for the first else-if, then for the second else-if, then for the else statement.
  • So when the, if-statement gets false which, means that the value of x is less than or equal to 10. So there is no need to check this on the first else-if statement by the help of "x<=10" condition.
  • And when the first else if the statement is getting false, then it is understood that the value of x is less than or equal to 6, so there is no need to put the condition "x<=6" in the second else-if statement.
  • So the above code is true but there is no needs to have "x<=10" and "x<=6" statement in an else-if statement.
  • And This is states from option A. Hence Option A is the correct answer while the other option is not correct because they state that statement which is necessary for the above code.
You might be interested in
Four actions that can be implemented on a database to autocorrect violations of referential integrity, and the outcomes of the a
Paraphin [41]

Answer:

Follows are the matching to this question:

Option \ a \to \ Option \ 3\\\\Option \ b \to \ Option \ 4\\\\Option \ c \to \ Option \ 1\\\\Option \ d \to \ Option \ 2\\

Explanation:

While time-consuming or prone to errors mechanical adjustments to both the referential, databases could be configured with four measures to engine violations. The restricted action causes the insert, update, and removes to only be denied. Set Null to NULL sets the invalid external key, whereas Set Default to a specific core consideration specified in SQL sets a default foreign key. Its Cascade operation spreads the main changes in external keys.

6 0
3 years ago
Develop a C program that calculates the final score and the average score for a student from his/her (1)class participation, (2)
Ghella [55]

Answer:

#include <iomanip>

#include<iostream>

using namespace std;

int main(){

char name[100];

float classp, test, assgn, exam, prctscore,ave;

cout<<"Student Name: ";

cin.getline(name,100);

cout<<"Class Participation: "; cin>>classp;

while(classp <0 || classp > 100){  cout<<"Class Participation: "; cin>>classp; }

cout<<"Test: "; cin>>test;

while(test <0 || test > 100){  cout<<"Test: "; cin>>test; }

cout<<"Assignment: "; cin>>assgn;

while(assgn <0 || assgn > 100){  cout<<"Assignment: "; cin>>assgn; }

cout<<"Examination: "; cin>>exam;

while(exam <0 || exam > 100){  cout<<"Examination: "; cin>>exam; }

cout<<"Practice Score: "; cin>>prctscore;

while(prctscore <0 || prctscore > 100){  cout<<"Practice Score: "; cin>>prctscore; }

ave = (int)(classp + test + assgn + exam + prctscore)/5;

cout <<setprecision(1)<<fixed<<"The average score is "<<ave;  

return 0;}

Explanation:

The required parameters such as cin, cout, etc. implies that the program is to be written in C++ (not C).

So, I answered the program using C++.

Line by line explanation is as follows;

This declares name as character of maximum size of 100 characters

char name[100];

This declares the grading items as float

float classp, test, assgn, exam, prctscore,ave;

This prompts the user for student name

cout<<"Student Name: ";

This gets the student name using getline

cin.getline(name,100);

This prompts the user for class participation. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Class Participation: "; cin>>classp; </em>

<em> while(classp <0 || classp > 100){  cout<<"Class Participation: "; cin>>classp; } </em>

This prompts the user for test. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Test: "; cin>>test; </em>

<em> while(test <0 || test > 100){  cout<<"Test: "; cin>>test; } </em>

This prompts the user for assignment. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Assignment: "; cin>>assgn; </em>

<em> while(assgn <0 || assgn > 100){  cout<<"Assignment: "; cin>>assgn; } </em>

This prompts the user for examination. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Examination: "; cin>>exam; </em>

<em> while(exam <0 || exam > 100){  cout<<"Examination: "; cin>>exam; } </em>

This prompts the user for practice score. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Practice Score: "; cin>>prctscore; </em>

<em> while(prctscore <0 || prctscore > 100){  cout<<"Practice Score: "; cin>>prctscore; } </em>

This calculates the average of the grading items

ave = (int)(classp + test + assgn + exam + prctscore)/5;

This prints the calculated average

cout <<setprecision(1)<<fixed<<"The average score is "<<ave;  

8 0
3 years ago
​a(n) ____ is a communications device that connects a communications channel such as the internet to a device such as a computer
marissa [1.9K]
Router? Modem? I have no ideas outside of those.
8 0
3 years ago
Combination of one or more columns used to identify particular rows in a relation is a (n)<br>​
Licemer1 [7]

Answer:

Combination of one or more columns used to identify particular rows in a relation is a key

5 0
3 years ago
I need help with question 3 I’ll give brainliest
Semmy [17]

Answer:

D) Engineering and Technology

Explanation:

Brent Designs or <em>Engineers </em>the equipment or<em> Technology </em>that is used to keep the plant safe.

7 0
3 years ago
Read 2 more answers
Other questions:
  • select three types of school which specifically emphasize learning through creativity, self expression, and play
    10·2 answers
  • La inteligencia o unidad lógica de un computador se denomina como??? Software, Hardware CPU o que, ayuda.....
    7·1 answer
  • Give two reasons why it is important to upgrade your browser when a new version becomes available.
    8·1 answer
  • Explain in detail what it means to synchronize computers and mobile devices. include at least two strategies for keeping your fi
    7·1 answer
  • To increase the view of a document on the screen, use the _____. View icon Zoom slider full-screen reading boldface font
    9·1 answer
  • _________ is a protocol used by e-mail clients to download e-mails to your computer. (
    6·1 answer
  • In a relational database, the three basic operations used to develop useful sets of data are:_________.
    14·1 answer
  • What might a designer need to consider when choosing an appropriate energy source for products and power systems
    15·1 answer
  • Which option ensures that items in a text box or table cell will be in the absolute center of that element?
    12·1 answer
  • What component of a change management program includes final testing that the software functions properly
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!