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
Rasek [7]
3 years ago
7

Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable sum tha

t has already been declared and initialized to 0. In addition, there is another variable, num that has also been declared. You must not use any other variables.
Computers and Technology
1 answer:
Strike441 [17]3 years ago
6 0

Answer:

public class num9 {

   public static void main(String[] args) {

       int sum =0;

       int num =5;

       for(num =5; num<=500; num+=5){

           System.out.println(num);

           sum +=num;

       }

       System.out.println(sum);

   }

}

Explanation:

  • Declare and initialize the variables sum and num
  • Use a for loop with the condition for(num =5; num<=500; num+=5) Since the loop will increment by 5 and run from 5 to 500
  • Within the loop, add num to sum at each iteration
  • Print all elements on seperate lines
  • Outside the loop, print the final value of sum

Create a for loop

You might be interested in
What are the advantages of using the internet as theinfrastructure for electronic commerce and electronicbusiness?
Mrac [35]

Answer and Explanation:

E-commerce and e-business is a major business of the present time using the internet. It is basically defined as the online selling of goods or making any business online. Internet is the basic requirement for the e-commerce or e-business as

  • it helps in providing the internet connectivity so that the e-business can be displayed online and users can buy goods or interact with seller regarding the business.
  • Due to internet service users get to know about the online business and thus the business attains economic growth and benefit.

6 0
3 years ago
If you would like to compare information on two different Web pages, you should _____.
Gekata [30.6K]

Answer:

Use Tabs

Explanation:

I had this lesson on odyessy ware and this was right the other guy is wrong

4 0
3 years ago
Read 2 more answers
At which stage should James, a website designer, gather information about the website he wants to create, and at which stage sho
viva [34]
<h2>Answer: James should gather information in the <u><em>Learning</em></u> phase and begin the site’s coding in the <u><em>Development</em></u> phase.</h2>

8 0
3 years ago
What is an implicit benefit to Monetary Policy?
Mariana [72]
The answer to your question is a
6 0
3 years ago
Many financial experts advise that property owners should insure their homes or buildings for at least 80 percent of the amount
serious [3.7K]
All I will say is good luck. because it can be very difficult to find someone that is willing to do this.
5 0
3 years ago
Other questions:
  • Consider the following class definitions. public class BClass { private int x; public void set(int a) { x = a; } public void pri
    11·1 answer
  • How to eject a flash drive from chromebook?
    6·1 answer
  • Is frequency measured in henry.
    14·1 answer
  • A computer operating system software manufacturer invests its profits in creating newer versions of its operating system softwar
    7·1 answer
  • Fill in the blanks:<br>Can anyone help me out with this <br>​
    9·1 answer
  • What is a mod in programming?<br><br> Give more Java questions
    12·1 answer
  • I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
    8·2 answers
  • Explain the concept of “survival of the fittest”
    15·1 answer
  • Why do computers use binary code?
    12·2 answers
  • Where is the element coded in a web page.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!