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
Lana71 [14]
4 years ago
12

Given that n refers to a positive integer, use a while loop to compute the sum of the cubes of the first n counting numbers, and

associate this value with total. Use no variables other than n, k, and total.
Computers and Technology
1 answer:
Rasek [7]4 years ago
6 0

Answer:

int k = 1;

int total = 0;

while (k <= n){

  total = total + (k*k*k);

  k++;

}

Explanation:

The code above has been written in Java.

Following is the line-by-line explanation of the code written as comments.

// Initialize int variable k to 1.

// variable k is used to control the loop.

// It is initialized to 1 because the positive integers should start at 1.

// Starting at zero will be unimportant since the cube of 0 is still zero and

// has no effect on the overall sum of the cubes.

int k = 1;

// Initialize total to zero(0)

// This is so because, at the start of the addition total has no value.

// So giving it zero allows to cumulatively add other values to it.

// Variable <em>total </em>is also of type int because the sum of the cubes of counting

// numbers (which are positive integers) will also be an integer

int total = 0;

// Now create a while loop to repeatedly compute the sum of the cubes

// while incrementing the counter variable <em>k</em>.

// The condition for the loop to execute is when <em>k</em> is less than or equal to

// the value of variable <em>n.</em>

// The cube of any variable k is given by k^{3} which can be

// written as k * k * k.

// At every cycle of the loop, the cube of the counter <em>k</em> is calculated and

// added cumulatively to the value of <em>total</em>. The result is still stored in the

// variable <em>total. </em>After which <em>k</em> is incremented by 1 (k++).

while (k <= n) {

  total = total + (k*k*k);

  k++;

}

You might be interested in
The oldest "computer" is thought to be how old? please help i beggiging 20 points
igomit [66]
The oldest “computer” is2,000 years old.

5 0
3 years ago
Read 2 more answers
Design the logic for a program that outputs every number from 1 through 15.
ankoles [38]
Not sure what programming language, but i'll use Java

print (1)
print (2)
print (3)
print (4)
print (5)
print (6)
print (7)
print (8)
print (9)
print (10)
print (11)
print (12)
print (13)
print (14)
print (15)
3 0
3 years ago
Read 2 more answers
Which kind of image is indispensable and needs added text to go with it?
STatiana [176]

Answer:

A chart and a graph

Explanation:

8 0
3 years ago
Help please fast
Pachacha [2.7K]
Bookmark because you can go back to it at any given time to re use it
4 0
3 years ago
Read 2 more answers
What are the programs in a computer​
stealth61 [152]

Answer:

Computer skills examples

Operating systems  

Office suites  

Presentation software

Spreadsheets  

Accounting software

Explanation:

A program is a set of ordered operations for a computer to do in computing. The program in the modern computer described by John von Neumann in 1945 has a one-at-a-time series of instructions that the computer follows. Typically, the application is saved in a computer-accessible storage location.

4 0
3 years ago
Other questions:
  • Define the term e-learning​
    5·2 answers
  • Match the technology with the appropriate task.
    7·1 answer
  • What is the definition of delimited text?
    14·2 answers
  • How would you convert an integer value to a float value in Python?
    10·1 answer
  • What is better apple or andriod
    11·2 answers
  • Generate a row vector b=[1 2 3 4 5 6 7 8 9 10] using linspace function, give the commands and show print-screen of the result.
    11·1 answer
  • I have put the question in twice and I cannot get a answer for it .. this site isn’t great in my view..
    9·1 answer
  • PLEASE HELP 10 POINTS!!!Click this link to view O*NET’s Work Activities section for Human Resources Managers. Note that common a
    7·2 answers
  • When you started the vi editor, you forgot to specify the name for the new file you are creating. To save steps next time, how c
    14·1 answer
  • A coworker is taking a computer overseas and asks you what concerns he should have. What do you tell him
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!