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
The weakest hydrogen line stars are classified as:
Ostrovityanka [42]
O is the weakest hydrogen line
7 0
4 years ago
Read 2 more answers
The item in this illustration that is highlighted is the _____. quick access tool bar view buttons status bar zoom control
tiny-mole [99]

Answer: scrollbar

Explanation:

7 0
3 years ago
Read 2 more answers
What is LATEX ? <br>create a latex command
AVprozaik [17]

Latex is a software used for writing daily life issue like integrations,fractions ,limits .

Lets see an example

\\ \bull\tt\longmapsto \displaystyle{\int}vdx

\\ \bull\tt\longmapsto \displaystyle{\lim_{x\to 0}}

5 0
3 years ago
What are two ways the broad-match modifier makes Jamie's work easier? (Choose two.)
Mariana [72]

Answer:

1) She doesn’t have to think of all the related saucepan keywords

2) She can easily select the colour she wants to focus on.

Explanation:

Broad match modifiers ensure  ads will only show for searches that include the words you’ve marked with a plus sign, such as +blue +suede +shoes. Broad match modifiers can help your keywords reach a greater clickthrough rate (CTR) with a more targeted customer audience, which in turn can help your site get more paying customers or other conversions

4 0
4 years ago
Write a SELECT statement that returns the category_name column from the Categories table. Return one row for each category that
KengaRu [80]

Answer:

Below is the required statement:

Explanation:

select c.categoryname

from categories c

where not exists (select 1 from products p where p.categoryid = c.categoryid);

6 0
3 years ago
Other questions:
  • Okay so remember that page I was advertising? At: fol ? Now it's deleted. And idk why because I was doing everything the right w
    7·1 answer
  • When a fighter pilot crosses into the airspace of another country without permission it can be considered an act of aggression o
    8·1 answer
  • if your instructors teaching style is very different from your learning preference your best choice is to one work on your weake
    10·1 answer
  • Refer to the exhibit, a technician applies the configuration in the exhibit to an unconfigured router. To verify the configurati
    13·1 answer
  • Jason Is Working On A Video Science Project. As He Is Working On It, He Saves The Project.
    5·1 answer
  • Having friends who cause you stress can decrease your happiness, which can in turn
    13·2 answers
  • One benefit proprietary licensed software is that it
    9·1 answer
  • Egovernment involves the use of strategies and technologies to transform government by improving the delivery of services and en
    7·1 answer
  • What is the encoding technique called that is used to store negative numbers in the computer's memory
    10·1 answer
  • Enterprise software is designed for organizations to __________.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!