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
__ provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debu
grin007 [14]

Answer:

java IDE

Explanation:

<h2><u>Fill in the blanks </u></h2>

<u>Java IDE</u> provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface.

7 0
3 years ago
What power brake uses vacuum from the engine to aid in brake application?
viktelen [127]
In a car I think I am not sure yet
4 0
3 years ago
Read 2 more answers
The type of human hair wig that is the most costly is:
RSB [31]

Answer: india

Explanation:

5 0
3 years ago
"If possible, always bring print-outs of your slides for your audience
taurus [48]
Why do I need a ty for me a couple days to
4 0
3 years ago
Read 2 more answers
Which of the following is not a valid variable name? 2 myInt 2. return 3. myInteger 4. total3
Reptile [31]

Answer:

Correct answer is option (2) that is "return".

Explanation:

In any programming language, a variable name can be made up of letters (lower and upper case) and digits. we can also use "_" underscore character for declaring the variables but we cannot use any special character like “$”.We cannot use digits in the beginning of variables name. And we also cannot use reserved keywords of the language like "new","return","while" etc. There should not be space between the variable names. Options 1, 3 and 4 are not violating any of these properties. But in option (2), "return" is a reserved keyword. That is why it is not a valid variable name.

Some example of valid variables name:

foo

BAZ

Bar

_foo42

foo_bar

Some example of invalid variables name:

$foo    ($ not allowed)

while   ( keywords )

2foo    (started with digit)

my foo  (spaces )

5 0
4 years ago
Other questions:
  • If you like to spend time outdoors working with plants and animals, you have a(n) _____. a. bodily/kinesthetic learning style b.
    6·2 answers
  • How many fonts are there in a theme?<br> A. 1<br> B. 2<br> C. 4<br> D. 5
    10·1 answer
  • I cannot figure out how to cancel my Brainly subscription. I can’t click “account settings” and “cancel subscription” cuz when I
    5·2 answers
  • Which tables and fields would you access to determine which book titles have been purchased by a customer and when the order shi
    15·1 answer
  • ​ In addition to using national weather sites, you should supplement the local weather information with all of the following EXC
    12·1 answer
  • A method that movie distributors are adopting to make it possible to view movies instantly, without DVD, is known as:
    11·1 answer
  • What are the disadvantages of using photo editing software in photography?
    14·1 answer
  • Which tab should you use to change the text font color in your presentation?
    15·1 answer
  • В.
    11·1 answer
  • Use USB in a sentence
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!