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
Ksenya-84 [330]
4 years ago
12

Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is read, count how many positive numbers are

read, and also compute the sum of only positive numbers, and display the count and the sum of positive numbers in different lines. Note that 0 is not included in the computations.
Computers and Technology
1 answer:
Artyom0805 [142]4 years ago
8 0

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {

       compute_pos();

     }

     

     public static void compute_pos(){

     Scanner scan = new Scanner(System.in);

     int sum = 0;

     int counter = 0;

     // Prompt the user to enter an input

     System.out.println("Enter your value");

     // user input is assign to the variable value

     int value = scan.nextInt();

     

     while(value != 0){

         if (value > 0){

             sum += value;

             counter++;

         }

         System.out.println("Enter your value");

         value = scan.nextInt();

     }

     // Display the value of sum to the user

     System.out.println("The sum of the positive number is: " + sum);

     // Display the value of counter to the user

     System.out.println("The number of positive number is: " + counter);

   }

}

Explanation:

The first line import the Scanner class which allow the program to read input from the user. The class Solution is then defined. Then the main method which signify the beginning of execution in the program is defined. A method is called inside the main method.

The method compute_pos is defined. Inside the compute_pos method, a scanner object scan is declared to accept input from the user via the keyboard.

The variable sum and counter is declared and assigned to 0.

A prompt is displayed to the user to input a value. The user input is accepted and stored in the variable value.

Then a while loop is use to check the user input if it is not equal to zero. If it is equal to zero, the loop will end. Inside the loop, we first check to see if the user input is greater than 0, if it is, we add it to the variable sum and increase our counter by 1. At the end of the loop, a prompt is again display to accept input from the user.

Outside the loop, we display the sum and counter to the user.

You might be interested in
When an instance of a class, or object, is specified as a parameter to a method, a reference to the said object is passed to the
OLEGan [10]
Or pointer

VERY similar.
5 0
3 years ago
Match the description to the step in troubleshooting.
Digiron [165]
It should go 4 5 3 2 1
5 0
3 years ago
Game Informer (often abbreviated to GI) is an American-based monthly magazine featuring articles, news, strategy, and reviews of
Eddi Din [679]

Answer:

it is d i just took it

Explanation:

6 0
3 years ago
Read 2 more answers
Edhesive 4.3 code practice question 2
Arturiano [62]
Sos shacahacwhaveusbsusvs js

8 0
3 years ago
Set the Append Only property to _____ to allow users to add data to a Long Text field but not to change or remove existing data.
diamong [38]

A computer data storage is made of many features. Set the Append Only property to YES to allow users to add data to a Long Text field but not to change or remove existing data.

  • Append-only is known to be a characteristic or component of computer data storage. It is where new data can be appended to the storage, but where existing data is said to be immutable.

A field's data type is very essential property as it shows what kind of data the field can store.

Learn more from

brainly.com/question/24795103

7 0
3 years ago
Other questions:
  • The _______ valve protects the air pump from reverse-exhaust pressure.
    11·1 answer
  • Ryan needs to see the space available to insert content on a slide in his presentation. Which feature of a presentation program
    5·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
  • A model is replica that?
    11·2 answers
  • Normalization works through a series of stages called normal forms. For most purposes in business database design, _____ stages
    7·2 answers
  • What are the steps to open the Custom AutoFilter dialog box?
    5·2 answers
  • Discuss five domains of Instructional technology​
    7·1 answer
  • How do you loop a makebeat in earsketch
    11·1 answer
  • An online supermarket wants to update its item rates during the sales season. They want to show the earlier rates too but with a
    6·2 answers
  • Please help me I don’t know what I’m doing wrong.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!