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
Veronika [31]
2 years ago
7

Write a program with a loop that lets the user enter a series of positive integers. The user should enter −1 to signal the end o

f the series. The program should count all the numbers entered, compute the running total of the numbers and displays their count, total and average. Display average to decimal places.
Computers and Technology
1 answer:
Fiesta28 [93]2 years ago
5 0

Answer:

import java.util.Scanner;

public class num2 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int count =0;

       int total = 0;

       System.out.println("Enter the numbers");

       int num = in.nextInt();

       while(num!=-1){

           total = total+num;

           count++;

           System.out.println("Enter the next number");

           num = in.nextInt();

       }

//Compute the average

       double average = (double) total/count;

//Outputs

       System.out.println("Total count of numbers entered "+(count));

       System.out.println("Sum of the numbers "+total);

       System.out.printf("Average is %.2f ",average);

   }

}

Explanation:

  • Using java programming language
  • Import scanner class to receive user input
  • declare variables count and total and initialize to zero
  • Prompt user to enter numbers
  • Use a while statement with the condition while(num!=-1)
  • Within the while body keep prompting user to enter a number, increase count and update total
  • when -1 is entered the loop breaks and average is calculated
  • Use printf() method to print average to 2 decimal places.
You might be interested in
Create a PHP page that contains an array of at least 20 movie titles or book titles (your choice). The HTML page should have an
ella [17]

Answer:

This is the code

Explanation:

<html>

<form method="POST" action="welcome.php">

label for="usname">username:</label><br>

<input type="text" id="usname" name="usname"><br>

<label for="movietitles">Movietitles</label><br>

<textarea type="text" id="movetitle" name="movietitles">Please enter movie titles</textarea>

<input type="submit">

</form>

</html>

<?php

$Movietitles= array("bland", "decoy","Mademan", "Rich", "bland", "decoy","Mademan", "Rich", "bland", "decoy","Mademan", "Rich" , "bland", "decoy","Mademan", "Rich, "decoy","Mademan", "Rich", "Adapt" );

$username= $_POST['username'];

if (!empty($_POST['username'])) {

$username = $_POST['username'];

echo "Welcome";

}

?>

The post method HTTP request is used to send the data from the form to the Welcome.php file above so that it validates/tests that username has been entered using the php if statement and if it is not empty(entered username) php "echos" welcome to the screen.

5 0
3 years ago
Data ____ refers to the accuracy of the data in a database
Brilliant_brown [7]
Accuracy or quality?
7 0
2 years ago
What does xhtml stand for?
igomit [66]
Extensible Hypertext Markup Language.
3 0
2 years ago
Read 2 more answers
Sorry to bother you guys but for some reason it wont let me comment. How can i fix this?
Step2247 [10]

Explanation:

I would just say close the app and come back in after

7 0
2 years ago
Read 2 more answers
6.4 Predicting Prices of Used Cars. The file ToyotaCorolla.csv contains data on used cars (Toyota Corolla) on sale during late s
Brums [2.3K]

Answer:

Compare the predictions in terms of the predictors that were used, the magnitude of the difference between the two predictions, and the advantages and disadvantages of the two methods.

Our predictions for the two models were very simmilar. A difference of $32.78 (less than 1% of the total price of the car) is statistically insignificant in this case. Our binned model returned a whole number while the full model returned a more “accurate” price, but ultimately it is a wash. Both models had comparable accuracy, but the full regression seemed to be better trained. If we wanted to use the binned model I would suggest creating smaller bin ranges to prevent underfitting the model. However, when considering the the overall accuracy range and the car sale market both models would be

Explanation:

8 0
3 years ago
Other questions:
  • In three to five sentences, describe how good e-mail work habits increase workplace efficiency and productivity.
    12·1 answer
  • Put the following five steps in the order in which you would perform them to use the Paste Special function: ____. 1. Select and
    5·1 answer
  • A new company is upgrading a media workstation. The computer will be predominantly used for graphic intensive presentations, sli
    13·1 answer
  • Ben works at a top accounting firm in Salt Lake City and his responsibilities include developing individual and departmental goa
    9·1 answer
  • The person in charge of recording the sound should always
    15·1 answer
  • A file named numbers.txt contains an unknown number of lines, each consisting of a single positive integer. Write some code that
    6·1 answer
  • Given an integer n and an array a of length n, your task is to apply the following mutation to an: Array a mutates into a new ar
    5·1 answer
  • Actividades que puedes Aser con un martillo y su explicación
    8·1 answer
  • You are the administrator for the ABC Company. You are looking to install Windows Server 2016, and you need to decide which vers
    13·1 answer
  • A technique that was developed to determine whether a machine could or could not demonstrate the artificial intelligence known a
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!