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
Naily [24]
3 years ago
8

Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a

nd computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. Sample Run 1
Computers and Technology
1 answer:
nika2105 [10]3 years ago
3 0

Answer:

import java.util.Scanner;

public class NumbersStats {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int pos = 0, neg = 0, count = 0, num;

       double total = 0;

       System.out.print("Enter an integer, the input ends if it is 0: ");

       while (true) {

           num = in.nextInt();

           if(num == 0) break;

           if(num > 0) {

               pos++;

           } else {

               neg++;

           }

           total += num;

           count++;

       }

       System.out.println("The number of positives is " + pos);

       System.out.println("The number of negatives is " + neg);

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

       System.out.println("The average is " + (total/count));

   }

}

Explanation:

You might be interested in
Write a program that asks the user to enter a series of single digit numbers with nothing separating them. Read the input as a C
vladimir2022 [97]

Answer:

#include <stdio.h>

#include <string.h>

int main(){

   char number[100];

   printf("Number: ");

   scanf("%s", number);

   int sum = 0;

   for(int i =0;i<strlen(number);i++){

       sum+= number[i] - '0';

   }

           printf("Sum: %d",sum);

   return 0;

}

Explanation:

This declares a c string of 100 characters

   char number[100];

This prompts user for input

   printf("Number: ");

This gets user input

   scanf("%s", number);

This initializes sum to 0

   int sum = 0;

This iterates through the input string

   for(int i =0;i<strlen(number);i++){

This adds individual digits

       sum+= number[i] - '0';

   }

This prints the calculated sum

           printf("Sum: %d",sum);

   return 0;

4 0
3 years ago
HELP PLEASE NOW ASAP BRAINLIEST
charle [14.2K]
<span>Josie lives in an area where there are frequent power cuts. She should use a UPS (Uninterruptible Power Supply). It protects against damage to a computer's hard drive (data) in case of a sudden shutdown.

Hope this helps!</span>
7 0
3 years ago
Read 2 more answers
Aubrey uses the following formula to calculate a required value. Which elements of the formula use mixed cell referencing?
iris [78.8K]

Answer:

$1A

brainiest plz

Explanation:

The elements of a formula only can have the following format:

1) Letter Number as C1

2) Letter $ Number as A$1

3) $ Letter Number as $A1

4) $ Letter $ Number as $A$1

The element $1A is not in the format

5 0
2 years ago
Read 2 more answers
What is a social media networks
Mumz [18]

You mean social networking? If so, Social networking is the use of Internet-based websites to stay connected with friends/family/anyone really. Social networking can have a social purpose, a business purpose, or both, through various websites. Hope this helps!! :)

4 0
3 years ago
In addition to the cost of legal services and the cost of treatment, which of the following are considered direct costs for work
Mrrafil [7]

Answer:

what are the options for the question

3 0
2 years ago
Other questions:
  • WILL GIVE BRAINLIEST! I'm doing a project at school. Does anyone have any good explanations for Digital Art? I need it to be at
    13·2 answers
  • What are the meaning master files<br>​
    8·1 answer
  • Jawana has been working on a paper for her Anatomy class for weeks. One day her little brother was on her computer and accidenta
    14·1 answer
  • What is the value of length after the code that follows is executed?int[][] nums = { new int [] {1, 2, 3},new int [] {3, 4, 5, 6
    8·1 answer
  • J. A computer on a network that acts as the central storage location for
    5·1 answer
  • You are asked to monitor a network which has a network monitoring system. Using the monitoring server, you notice that it is lis
    13·1 answer
  • Write a program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name wil
    13·1 answer
  • Create another method: getFactorial(int num) that calculates a Product of same numbers, that Sum does for summing them up. (1,2,
    7·1 answer
  • In a three-tier architecture, the component that runs the program code and enforces the business processes is the:_______.
    11·1 answer
  • What does this map key show
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!