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
cluponka [151]
3 years ago
10

What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 11) { sum = sum + i; i++; } System.out

.println("The value of sum is " + sum); The value of sum is 65. The value of sum is 66. The value of sum is 55. The value of sum is 56.
Computers and Technology
1 answer:
valentina_108 [34]3 years ago
7 0

Answer:

The value of sum is 66

Explanation:

i = 1

sum = 0

while (i <= 11) {  

sum = sum + i;

i++;  

}

i = 1

  • sum = sum + i
  • sum = 0 + 1
  • sum = 1

i = 2

  • sum = sum + i
  • sum = 1 + 2
  • sum = 3

i = 3

  • sum = sum + i
  • sum = 3 + 3
  • sum = 6

i = 4

  • sum = sum + i
  • sum = 6 + 4
  • sum = 10

i = 5

  • sum = sum + i
  • sum = 10 + 5
  • sum = 15

i = 6

  • sum = sum + i
  • sum = 15 + 6
  • sum = 21

i = 7

  • sum = sum + i
  • sum = 21 + 7
  • sum = 28

i = 8

  • sum = sum + i
  • sum = 28 + 8
  • sum = 36

i = 9

  • sum = sum + i
  • sum = 36 + 9
  • sum = 45

i = 10

  • sum = sum + i
  • sum = 45 + 10
  • sum = 55

i = 11

  • sum = sum + i
  • sum = 55 + 11
  • sum = 66

i = 12 --> does not comply with the condition "i < = 11", the while loop is over

You might be interested in
IDENTIFYING VERBS THAT AGREE IN NUMBER WITH THEIR SUBJECTS For each of the following sentences, write the correct form of the ve
Novay_Z [31]

Hey there!

  • The word "<u>verb</u>" simply means <em>'description of an action, assert, or event that is made into the main purpose of your predicate in your judgement' </em>
  • Now that we have the definition of the word verb we can answer your question
  • "<em>Has</em>" is past tense but it is THIRD person present
  • "<em>Have</em>" is when you own something
<h2>Answer: HAS ✅</h2>

BECAUSE "I SAW last night"

Note: usually people read the sentence to themselves until it makes easier sense to them or use context clues in the sentence to answer the particular question(s)

Good luck on your assignment and enjoy your day!

~LoveYourselfFirst:)

6 0
3 years ago
Read 2 more answers
Lena is completing her senior year of college and is living in an apartment with three friends. Her family has a subscription to
vladimir1956 [14]

Answer:

d) consumer misbehavior

Explanation:

This is an example of consumer misbehavior. What Lena is doing is not technically piracy or illegal because HBO has created the family feature on their accounts for the account to be used by multiple people at the same time. Yet, the feature was not intended to be used by individuals that are not technically family or even under the same roof. Therefore, what Lena is doing goes against HBO's reason for this feature and sharing the account as Lena is doing is ultimately hurting HBO's streaming service.

4 0
2 years ago
Why is it important to follow a consistent naming convention for variables?
Vitek1552 [10]

Answer:

today I am going to be out for the job interview so if I will make it happen I am going to New Orleans this week to get the kids to work on the spot and I can get ready to go out to dinner and I can make a few more people

4 0
2 years ago
Construct a class that will model a quadratic expression (ax^2 + bx + c). In addition to a constructor creating a quadratic expr
stich3 [128]

Answer:

Following are the code to this question:

#include <iostream>//header file

#include<math.h>//header file

using namespace std;

class Quadratic//defining a class Quadratic  

{

private:

double a,b,c;//defining a double variable

public:

Quadratic()//defining default constructor

{

a = 0;//assigning value 0  

b = 0;//assigning value 0  

c = 0;//assigning value 0  

}

Quadratic(double a, double b, double c)//defining a parameterized constructor  

{

this->a = a;//use this keyword to hold value in a variable

this->b = b;//use this keyword to hold value in b variable

this->c = c;//use this keyword to hold value in c variable

}

double getA() //defining a get method  

{

return a;//return value a

}

void setA(double a)//defining a set method to hold value in parameter

{

this->a = a;//assigning value in a variable

}

double getB() //defining a get method  

{

return b;//return value b

}

void setB(double b)//defining a set method to hold value in parameter  

{

this->b = b;//assigning value in b variable

}

double getC() //defining a get method

{

return c;//return value c

}

void setC(double c)//defining a set method to hold value in parameter

{

this->c = c;//assigning value in c variable

}

double Evaluate(double x)//defining a method Evaluate to hold value in parameter

{

return ((a*x*x)+(b*x)+c);//return evaluated value

}

double numberOfReal()//defining a method numberOfReal to calculates the real roots

{

return (b*b)-(4*a*c);//return real roots

}

void findroots()//defining a method findroots

{

double d=numberOfReal();//defining double variable to hold numberOfReal method value

if(d<0)//use if block to check value of d less than 0

cout<<"Equation has no real roots"<<endl;//print message

else

{

double r1=(-b+sqrt(numberOfReal()))/(2*a);//holding root value r1

double r2=(-b-sqrt(numberOfReal()))/(2*a);//holding root value r2

if(r1==r2)//defining if block to check r1 equal to r2

cout<<"Equation has one real root that is "<<r1<<endl;//print message with value

else//else block

cout<<"The equation has two real roots that are "<<r1<<" and "<<r2<<endl;////print message with value

}

}

void print()//defining a method print  

{

cout<< a << "x^2 + " << b << "x + " << c <<endl;//print Quadratic equation

}

};

int main()//defining main method  

{

Quadratic q(5,6,1);//creating Quadratic class object that calls parameterized constructor

q.print();//calling print method

cout<<q.numberOfReal()<<endl;//calling method numberOfReal that prints its value

q.findroots();//calling method findroots

cout<<q.Evaluate(-1);//calling method Evaluate that prints its value

return 0;

}

Output:

5x^2 + 6x + 1

16

The equation has two real roots that are -0.2 and -1

0

Explanation:

In the above code, a class "Quadratic" is declared, which is used to define a default and parameter constructor to holds its parameter value.

In the next step, the get and set method is defined that holds and returns the quadratic value, and "Evaluate, numberOfReal, findroots, and print" in the evaluate method a double variable is used as a parameter that returns evaluated value.

In the "numberOfReal" method it calculates the real roots and returns its value. In the "findroots" method a double variable "d" is declared that hold "numberOfReal" value,

and use a conditional statement to check its value, and in the print method, it prints the quadratic equation.

In the main method, the lass object it calls the parameterized constructor and other methods.

5 0
3 years ago
The answer is family and friends
nadya68 [22]
Family and Friends



you said the answer was that, soooooo
5 0
3 years ago
Read 2 more answers
Other questions:
  • Fordham3 Hardware is known for its consensus buying center culture. Recognizing this corporate culture, someone attempting to se
    8·1 answer
  • Helppppppppppppppppppp
    11·1 answer
  • When building systems, the only two entities that constitute software engineering are people and process.
    9·1 answer
  • The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create
    10·1 answer
  • Why are there so many problems with drivers?
    15·1 answer
  • PLS HELP ASAP- Select the correct text in the passage.
    13·2 answers
  • Ask the user to input a word. Then, print the first letter, the last letter, and the length of the word on the same line with no
    6·1 answer
  • What can be done to solve unemployment problem?​
    11·1 answer
  • 5. Why do we need programming language?​
    13·2 answers
  • Select the correct answer.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!