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
konstantin123 [22]
2 years ago
11

As in previous prelabs, you can enter all the necessary Java code fragments into the DrJava Interactions pane. If you get an err

or, enter the corrected code. If you get really mixed up, you can reset the interactions pane and try again. Write a while loop that computes the sum of the first 10 positive integers. Write a for loop that computes the sum the first 10 positive integers. For each loop, you should use two variables. One that runs through the first 10 positive integers, and one that stores the result of the computation. To test your code, what is the sum of the first 10 positive integers
Computers and Technology
1 answer:
yuradex [85]2 years ago
5 0

Answer:

public class Main{

public static void main(String[] args) {

 //The While Loop

 int i = 1;

 int sum = 0;

 while(i <=10){

     sum+=i;

     i++;  }

 System.out.println("Sum: "+sum);

 //The for Loop

 int summ = 0;

 for(int j = 1;j<=10;j++){

     summ+=j;  }

 System.out.println("Sum: "+summ); } }

Explanation:

The while loop begins here

 //The While Loop

This initializes the count variable i to 1

 int i = 1;

This initializes sum to 0

 int sum = 0;

This while iteration is repeated until the count variable i reaches 10

 while(i <=10){

This calculates the sum

     sum+=i;

This increments the count variable i by 1

     i++;  }

This prints the calculated sum

 System.out.println("Sum: "+sum);

The for loop begins here

 //The for Loop

This initializes sum to 0

 int summ = 0;

This iterates 1 through 10

 for(int j = 1;j<=10;j++){

This calculates the sum

     summ+=j;  }

This prints the calculated sum

 System.out.println("Sum: "+summ); }

You might be interested in
A _____ is a form of Web conferencing that uses streaming media technologies to broadcast video and/or audio over the Internet f
ra1l [238]

Answer:

Webcast

Explanation:

Webcast is the live broadcast of a video or audio feed from your event or conference harnessing the internet. Webcast is a media presentation of an event circulated over the internet by using media technology to distribute a single source to various viewers.

Generally,  webcast is briefly defined as broadcasting over the internet. The broadcast might not be specifically live  . One can capture the video or the audio he or she wants to publish and publish it online anywhere. Webcast allow your viewers to remain engage as if they are face to face with the broadcaster.

Webcasting is a a great tools that has been used by various multinational and company to reach wide range of audience . This web based broadcast can even provide opportunity for audience to ask question and even provide answers in real time.

4 0
3 years ago
Read 2 more answers
PHP Create a for loop that initialize with the variable $i = 10 The loop outputs $i as long as $i is greater than 1 using for lo
Tanzania [10]

Answer:

The PHP code is as follows

<?php

for ($i = 10; $i>1; $i--)

{

echo $i.' ';

}

?>

Explanation:

The code is self explanatory and doesn't require comments before it can easily understood.

The program starts with a php opening tag <?php

And it ends with the closing tag ?>

The interpretation of the question is to print integer values from 10 to 1

To do this, an iteration is needed.

The above program makes use of a for loop iteration.

Analysis;

for ( -> This shows that it is a for loop iteration

$i = 10; -> Iterating variable $i is initialized to 10 (that is; printing will start at 10)

$i>1; -> Iteration is valid while $i is greater than 1 (e.g. 2,3,4...10)

$i-- -> For every Iteration, decrease $i by 1

) -> End of Iterating condition

echo $i.' '; -> This line prints the valid values of $i. In this case, the values of $i is from 10 and stops at 2

The output is as follows

10 9 8 7 6 5 4 3 2

4 0
3 years ago
Type the correct answer in the box. Spell all words correctly.
Tom [10]

Answer:

navigate keys

Explanation:

the up and down keys are to scroll through documents and pages.

8 0
3 years ago
Read 2 more answers
What is the output?
Aleksandr-060686 [28]

Answer:

The output of code is 20.

Explanation:

We need to give output of the following code:

numB = 25

while numB > 13:

numB = numB - 5

print(numB)

Solution:

We will check the condition of while loop, if the condition is true, then the statements inside the loop will be executed. Since brackets are not available so, only one statement is linked with while loop.

Executing the statements, we check condition while numB > 13 (25>13) is true, next statement will be executed numB = numB - 5  (20=25-13) so, when print(numB) will be executed, we will get 20.

The output of code is 20.

4 0
3 years ago
Read 2 more answers
Which country does coriander come from
lawyer [7]
Coriander comes from<span> Morocco and Romania</span>
4 0
3 years ago
Read 2 more answers
Other questions:
  • In your opinion, is it more beneficial to have many folders or is it better to “nest” subfolders? Explain your response.
    10·2 answers
  • Scavenging is a form of fraud in which the perpetrator uses a computer program to search for key terms in a database and then st
    14·1 answer
  • The system restore utility can be started from command line using what executable?
    11·1 answer
  • ​if a primary key combines two or more fields, then it is called a _____.
    14·1 answer
  • Josh wants to convey his best wishes to johnathin for a meeting schedualed later diring the day. Which business documented would
    7·1 answer
  • What are the two ways to print a document?
    11·1 answer
  • What are ip addresses? why are these important for forensic scientists?
    5·1 answer
  • At the beginning of Section 5.2, it is stated that multiprogramming and multiprocessing present the same problems, with respect
    8·1 answer
  • [1] Our son has started playing organized T-ball, a beginner’s version of baseball. [2] “Organized” is what parents call it, any
    9·2 answers
  • The process of redefining the functionality of a built-in operator, such as , -, and *, to operate on programmer-defined objects
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!