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
Nimfa-mama [501]
3 years ago
7

Write a for loop that runs 5 times and accepts the input of an integer number every time. Those numbers will be accumulated by a

variable called total.
Computers and Technology
1 answer:
eduard3 years ago
7 0

Answer:

import java.util.Scanner;

public class num2 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int total = 0;

       for(int i=0; i<5; i++){

           System.out.println("Enter next Int: ");

           total = total+in.nextInt();

       }

       System.out.println(total);

   }

}

Explanation:

In the code above written in Java programming language, the for loop statement for(int i=0; i<5; i++) ensures that the loop goes from 0-4 a total of five times.

At each iteration it requests a user to enter an int. The number entered is stored in the variable total which is initially assigned 0.

When the loop finishes execution, total is printed out

You might be interested in
Write an expression that executes the loop body as long as the user enters a non-negative number. Note: If the submitted code ha
madam [21]

Answer:

           while (Num>=0) {

               System.out.println("enter a another number");

               Num = in.nextInt();

           }

Explanation:

The complete java code prompting a user to enter a number until a negative number is entered is given below:

import java.util.Scanner;

public class num6 {

public static void main (String [] args) {

Scanner in = new Scanner(System.in);

System.out.println("enter a number");

int Num = in.nextInt();

while (Num>=0) {

System.out.println("enter a another number");

Num = in.nextInt();

}

System.out.println("Done.");

return;

}

}

3 0
3 years ago
4. Give four reasons why a laptop computer is more expensive than a desktop computer of the
kipiarov [429]
<h3>ANSWER:The main reason why laptops are more expensive than desktops is in the development costs to create hardware that is compact enough and at the same time meeting an expected level of performance.</h3>

<h3>And it’s not just performance that is a big challenge. It is also keeping the system cool enough that stability is maintained under most common usage conditions</h3>
3 0
3 years ago
You can use pen and highlighter tools to emphasize information on a slide during a PowerPoint presentation. These tools are avai
Savatey [412]
ANSWER:
C. Slide Show toolbar
5 0
3 years ago
What is the difference between First Person Shooters and Construction Simulations?
Marianna [84]

Answer:No clue

Explanation:

5 0
3 years ago
Read 2 more answers
Find the area of square whose perimeter is 260.8m​
inessss [21]
4251.04

The perimeter (260.8) over 4 is equal to each side length (65.2)

65.2^2 = 4251.04
5 0
3 years ago
Other questions:
  • "Which of the following will help protect against a brute force attack?
    11·1 answer
  • Scratch and grinding marks on sedimentary rocks indicate which type of environment?
    6·1 answer
  • A text-only forum accessed through a bulletin board service (BBS) is known as a _____.
    14·1 answer
  • What is the term for the conversion of a bitmap image to a vector image?
    8·1 answer
  • Write a program that uses for loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNu
    15·1 answer
  • Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guz
    15·1 answer
  • VOTE!
    11·1 answer
  • Which result is most likely if a network packet has no header?
    9·2 answers
  • What do earthquakes and tsunamis have in common?
    13·1 answer
  • How have these advances in-home technology changed the role of technicians in our society?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!