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
If a company gave you a free version of their software and encouraged you to try and improve it and share it with the only commu
dimulka [17.4K]

Answer:

Explanation:

crm

8 0
2 years ago
What is the difference between a manufacturing engineer and a materials engineer?
lyudmila [28]
<span> a </span>manufacturing<span> or industrial </span>engineer<span> are mechanical </span>engineers<span> with ... Process </span>Engineers<span> specialise in processes where raw </span>materials<span> are converted using chemical processes resulting in significantly </span>different<span> ...</span>
7 0
3 years ago
Read 2 more answers
Which of the following will track every single connection outside the Web by IP address and URL? Clipper Chip National Security
astraxan [27]

The answer is proxy server

A proxy server acts as an immediate or a gateway between you, the proxy client (example, the browser) and the internet or the destination website that you want to visit. Proxy servers are designed to re-route traffic and obscure source and destination. For instance, if you want to request a page like brainly, a proxy server will be able to retrieve this page for you by providing only its IP address to the site and act as a mediator between clients and the requested server. This however, does not mean that there is no link between you and this website. It means that all the information along with the requests you made will be collected by the proxy server.

4 0
2 years ago
Read 2 more answers
Harry is undertaking a digital photography course as the college and wants to
Ludmilka [50]

C. Unconventionally yes it will break down the system potentially causing a virus

4 0
2 years ago
Implement the function fileSum. fileSum is passed in a name of a file. This function should open the file, sum all of the intege
maria [59]

Answer:

/*C++ program that prompts user to enter the name of input file(input.txt in this example) and print the sum of the values in the file to console. If file dosnot exist, then close the program */

//header files

#include <fstream>

#include<string>

#include <iostream>

#include <cstdlib> //needed for exit function

using namespace std;

//function prototype

int fileSum(string filename);

int main()

{

string filename;

cout << "Enter the name of the input file: ";

cin >> filename;

cout << "Sum: " << fileSum(filename) << endl;

system("pause");

return 0;

}

/*The function fileSum that takes the string filename and

count the sum of the values and returns the sum of the values*/

int fileSum(string filename)

{

//Create a ifstream object

ifstream fin;

//Open a file

fin.open(filename);

//Initialize sum to zero

int sum=0;

//Check if file exist

if(!fin)

{

cout<<"File does not exist ."<<endl;

system("pause");

exit(1);

}

else

{

int value;

//read file until end of file exist

while(fin>>value)

{

sum+=value;

}

}

return sum;

}//end of the fileSum

Explanation:

This is a C++ program that prompts user to enter the name of input file(input.txt in this example) and print the sum of the values in the file to console. If file dosnot exist, then close the program.

Check attachment for sample output screenshot.

5 0
2 years ago
Other questions:
  • The picture that graphically represents the items you use in windows is called a/an
    5·1 answer
  • Tower Building Activity
    12·1 answer
  • Each row in a database is a set of unique information called a(n) (A.)table,(B.)record,(C.)object,(D.)field
    12·2 answers
  • In the URL, what is the subdomain and what is the domain name?
    5·1 answer
  • Why when I move stuff in Roblox Studio like an object or a Character. It tilts the opposite direction I'm moving it to with the
    6·2 answers
  • Which of the following refers to a collection of colors, fonts, and effects that can be
    6·1 answer
  • In C, how could I use a command line input to remove certain characters from an existing string? For example, if I have string '
    8·1 answer
  • Write a program to find the principle amount​
    10·1 answer
  • Which finger is used to press SHIFT key while typing!
    14·2 answers
  • How to execute python code in command prompt *window*?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!