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
sertanlavr [38]
2 years ago
8

This the code from the last post I did

Computers and Technology
1 answer:
Andrew [12]2 years ago
3 0

import java.util.Scanner;

public class JavaApplication86 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       int x = 0, c = 0, sum = 0;

       while (true){

           x = scan.nextInt();

           System.out.println("You entered: "+x);

           if (x == -1){

               break;

           }

           sum += x;

           c++;

       }

       System.out.println("The sum is "+sum);

       System.out.println("You entered "+c +" numbers");

   }

   

}

This works for me. Instead of subtracting one from c and adding one to sum, I used an if statement to break away from the while loop if the entered number is -1.

You might be interested in
Write a flowchart and C code for a program that does the following: Uses a do...while loop. Prints the numbers from 1 to 10 with
emmasim [6.3K]

Answer:

create the integer variable and initialize it to one, with the do statement, increment the variable by one and print it, then the while statement checks if the variable is less than or equal to 10.

#include <iostream>

using namespace std;

int main(){

   int i = 1;

   do {

       cout<< i << "\n";

       i++;

   }

   while (i <= 10);

}

Explanation:

The C++ source code initializes the integer variable i to one and increments and print the value if the value is less than or equal to ten. The do-while statement executes a block of code before the condition is implemented.

4 0
3 years ago
The approved detail design resulting from the __________ serves as a basis for making the decision to begin production.
natita [175]
I am pretty sure, that complete answer looks like this: The approved detail design resulting from the <span>Critical Design Review</span> serves as a basis for making the decision to begin production. Critical Design Review is needed to ensure that system can meet stated performance including costs and risks.
8 0
3 years ago
For which of the following is a bulleted list more appropriate than a numbered list?
Vedmedyk [2.9K]
THE ANSWER IS A!!!!!!!!!!!!!!!!!!!
5 0
3 years ago
Early photographers take to work with what in order to produce photographs? (Btw this is photography, it just isn't a subject in
Kruka [31]
1, they used to use chemicals.
4 0
3 years ago
Someone help me please
MA_775_DIABLO [31]

Answer:

I think it is the last 2 but i am not 100% sure.

Explanation:

3 0
2 years ago
Other questions:
  • "Dean wants a quick way to look up staff members by their Staff ID. In cell Q3, nest the existing VLOOKUP function in an IFERROR
    10·1 answer
  • What is the term for the process of gathering information through images taken at a distance?
    13·1 answer
  • A windows host sends a tcp segment with source port number 1200 and destination port number 25. the sending host is a(n) _______
    10·1 answer
  • ) How many switching functions of two variables (x and y) are there?
    11·1 answer
  • А.<br> is the highest education degree available at a community college.
    6·1 answer
  • A _____ is a harmful program that resides in the active memory of a computer and duplicates itself. Select one: a. scareware b.
    7·1 answer
  • Declare a variable temperature and initialize it to 98.6. Instructor Notes: Note that "initialize" means "declare and assign a v
    5·1 answer
  • Yall like portal 1 or 2
    8·1 answer
  • On his website, Mario has a video that visitors must click to play. He wants the video to play automatically when the page loads
    8·1 answer
  • I just wanna know how many times a day y'all hit the tutor button at the bottom
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!