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
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
maxonik [38]

Answer:

IF Condition lol

Explanation:

3 0
3 years ago
You asked your colleague to provide feedback on a blog post you recently wrote. When they sent you their feedback, they made edi
Soloha48 [4]

Explanation:

This question can have both answers that is yes as well as no.

1.Yes, it can serve as an editor who completes your content and ensures it will read well to others.

2. No, the editor should have tracked changes which would have shown you where they would apply recommended edits.

7 0
4 years ago
What is the home page on a website?
andriy [413]
I think the answer is D
3 0
4 years ago
Do all websites use the same coding to create?
Eduardwww [97]

I think not but I'm not sure

6 0
3 years ago
Which one of the following sstatements suggests a good method
PilotLPTM [1.2K]
The 2nd onnnnneeeeeee
7 0
3 years ago
Other questions:
  • Without a(n) ____, a computer cannot function.
    8·2 answers
  • To create a default value for a parameter in the parameter list of a function, you code a/an ________________ sign after the par
    5·1 answer
  • Activities that scan network locales for active systems and then identify the network services offered by the host systems is kn
    12·1 answer
  • An email address is made up of all of the following parts except
    13·2 answers
  • What are some of the good effects of social media
    7·1 answer
  • PLS ANSWER ASAP!
    9·1 answer
  • Select the correct answer.
    10·2 answers
  • To create a new table by using a select statement, you code the ___________________________ clause.
    14·1 answer
  • Display all the lines in unixPasswd that contain at least 10 consecutive lowercase letters. How many names are there in total th
    12·1 answer
  • What electronic devices do you use more frequently? And how much time do you use them?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!