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]
3 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]3 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
After an object has been instantiated, its methods can be accessed using the object's _____, a dot, and a method call
BigorU [14]
<span>After an object has been instantiated, its methods can be accessed using the object's identifier, a dot, and a method call.
</span>DOI stands for D<span>igital Object Identifier, to permanently identifies an article or document and link to it on the web and can be  </span><span>a string of numbers, letters and symbols.</span>
5 0
3 years ago
I need a quick way to see all hardware connected to my computer.
timofeeve [1]
Look it up..............
7 0
3 years ago
When you record a macro, you can assign it to run from a button or from the _____.
arsen [322]
Depends on what software you use and how you set it up. But yea it’s possible
3 0
4 years ago
Read 2 more answers
100 tickets are sold in a raffle with one prize. John has 8 tickets, Jamie has 10 tickets, find the probability that John wins
Reika [66]

\frac{8}{100} or \frac{2}{25}
7 0
3 years ago
Read 2 more answers
Hi guys help me plz . How to get ios 10 zip file for android devices ? or how to port ios 10 or higher for htc one me ?
Vladimir79 [104]
While you set up your new iOS device, look for the Apps & Data screen. Then tap Move Data from Android. (If you already finished setup, you need to  erase your iOS device and start over. If you don't want to erase, just transfer your content manually<span>.)</span>
4 0
3 years ago
Other questions:
  • Modify the Eggs program to create a new one named EggsInteractive that prompts the user for and accepts a number of eggs for eac
    13·1 answer
  • No processo fluido a fluido há outra câmara na saída do material extrudado com pressão menor que a câmara anterior. Isso permite
    8·1 answer
  • Match each label to the correct location on the image match the process to its characteristics
    14·1 answer
  • 3) Prompt the user for a 3-digit number, and the output should be the magical #, which is formed with each digit shifted to the
    13·1 answer
  • When a laptop internal device fails, what three options can you use to deal with the problem?
    7·1 answer
  • If you have 60fps on your laptop tell me one way you can go to 240fps
    14·2 answers
  • 1. The Bank manager is imposing a 10% interest rate on the new salary loan to every account in the BPI Family Bank. (ANSWER SHOU
    15·1 answer
  • Five technology tools and their uses​
    5·1 answer
  • A pointer can be used as a function argument, giving the function access to the original argument.
    8·1 answer
  • How do I get the pictures from my old Samsung phone to put on my iPhone? The Samsung is turned off. Is there a way to transfer i
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!