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
Why do I keep getting points if I haven't answered anything? I don't want points.
stepan [7]

Answer:

you get points for other things like logging on and asking questions

5 0
3 years ago
Does anyone know to get Google updated if it failed to update?
Yuri [45]
You adapt the situation and overcome the situation, look it up this is not school relevant
4 0
4 years ago
How can you make a search phrase more effective?
Rufina [12.5K]

Answer:

Keep it short: The fewer words you use, the more accurate your search will be. ...

Use quotes: Double quotes around a set of words tells gog.le to consider the exact words in that exact order without any change.

Search a web site: allows you to specify that your search results must come from a given website.

Explanation:

5 0
3 years ago
When Nathanil Inc, a network service provider, introduced 4G data plans, it observed that most of its customers completely stopp
svetoff [14.1K]
We did this at school not hard nor easy it C
6 0
3 years ago
Why would it be beneficial to preview a page before printing?
enyata [817]
To make sure it looks how you want it to look, or to make sure all the info is correct and we're it should be.
4 0
3 years ago
Other questions:
  • Which piece of information is most useful to an identity thief? *
    6·1 answer
  • question 4 What is the output of following program: public class Test { public static void main(String[] args) { A a = new A();
    12·1 answer
  • Write a method named lastFirst that accepts a string as its parameter representing a person's first and last name. The method sh
    13·1 answer
  • What is an example of the most important role of a systems analyst in any corporation?
    10·1 answer
  • What is entered into a cell that is typically numeric and can be used for calculations?
    9·2 answers
  • If you were practicing keyboarding and the exercise contained the letters, q, o, e, p, r, and t, what section of the keyboard ar
    12·1 answer
  • WILL UPVOTE ALL
    10·1 answer
  • Mrs. Sims polled her students about which social media app they use most. Which type of chart would best display this data?
    9·1 answer
  • 7. Four more than negative eleven times a number is 26.​
    7·2 answers
  • Will this website ever get itself together to stop people from sending links?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!