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
Ania has written this SimpleStopwatch class. In which line is she measuring the elapsed time?
babunello [35]

Answer:

Mona

Explanation:

6 0
2 years ago
What are your initial thoughts regarding copyright and fair use after watching the clip?
Elanso [62]
The answer is A you’re welcome
5 0
3 years ago
Special numeric has three digits and holds a property that it is exactly equal to summation of cubes from each digit. For exampl
Vera_Pavlovna [14]

Answer:

The following code is written in C programming language:

#include <stdio.h>     //header file

 

int main()       //main method

{

   int n, t, digit1, digit2, digit3;      // set integer variables

    // print message

   printf("Print all Special integer numbers between 100 and 999:\n");

   n = 100;      //initialize value in variable "n"    

   while (n <= 999)      //set while loop

   {

       digit1 = n - ((n / 10) * 10);

       digit2 = (n / 10) - ((n / 100) * 10);

       digit3 = (n / 100) - ((n / 1000) * 10);

       t = (digit1 * digit1 * digit1) + (digit2 * digit2 * digit2) + (digit3 * digit3 * digit3);

       if (t == n)      //set if statement

       {

           printf("\n Special integer number is: %d", t);     //print an output

       }

       n++;

   }

}

Output:

Print all Special integer numbers between 100 and 999:

Special integer number is: 153

Special integer number is: 370

Special integer number is: 371

Special integer number is: 407

Explanation:

Here, we set the header file "stdio.h".

Then, we define integer type "main()" function.

Then, we set five integer type variable "n", "t", "digit1", "digit2", "digit3".

Then, we the print message by print() method and initialize a value to variable "n" to 100.

Then, we set the while loop which starts from 100 and stops at 999 and if the condition is true than code inside the loop is execute either loop is terminated.

Then, we set the if statement and pass the condition, if the condition is true the output would be print either if the condition is false the if statement is terminated.

8 0
3 years ago
Mengapakah wanita hamil memerlukan jumlah nutrien yang lebih banyak berbanding wanita tidak hamil.
Elan Coil [88]

Answer:

Because of the baby in the womb

Explanation:

Remember, a pregnant woman carries a life (the fetus) in her womb, and the unborn child depends on its mother for food. Such a complex and fascinating stage of pregnancy requires the mother to be well-nourished or else the child may die or suffer some health problems; which may even affect the mother.

5 0
3 years ago
Why people get addited to mobile and by playing games​
nadya68 [22]
Because it is a very fun game and if it is fun people like it
4 0
3 years ago
Other questions:
  • Approximately what percent of U.S. businesses have some form of remote work program? (from Chapter 1)
    14·1 answer
  • ¿Cuál es el objetivo principal de los servicios?
    7·1 answer
  • All ofthe following are correct EXCEPT one option when it comes towriting disappointing news letters. Identify theexception.
    6·1 answer
  • A ____ client locates all or most of the processing logic on the server.
    11·1 answer
  • Escribe, en los siguientes cuadros, los conceptos que correspondan
    10·1 answer
  • Do the shape of a sign gives you a clue about the information contained on the sign
    7·1 answer
  • Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMile
    10·1 answer
  • 9. "मेरे तो गिरधर गोपाल, दूसरो ना कोई
    5·1 answer
  • What are the paparazzi?
    8·1 answer
  • Which tab on the Ribbon contains the command to print a publication?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!