Write a program that reads a set of floating-point values

Assignment Help Computer Engineering
Reference no: EM132211343

Question :

Write a program that reads a set of floating-point values. Ask the user to enter the values (prompting only a single time for the values), then print:

-the average of the values.

-the smallest of the values.

-the largest of the values.

-the rage, that is the difference between the smallest and largest.

Your program should use a class DataSet. That class should have a method public void add(double value) and methods getAverage, getSmallest, getLargest, and getRange.

So there needs to be a classDataSet, and a DataSetTester.

I've provided both below, but I'm not sure what exactly to place into each. Help? Thanks.

public class DataSet { //public class

private double value=0; //instance variables that should be initialized.

private double sum=0;

private int count=0;

private double smallest=0;

private double largest=0;

public void add(double value){

sum =+ value;

}

public void getAverage(){

while (sum >0){

count++;

double average = sum/count;

}

}

public void getLargest(){

if (value > largest)

largest = value;

}

public void getSmallest(){

if (value<smallest)

smallest = value;

}

public void getRange(){

double range = largest - smallest;

}

}

***********

import java.util.Scanner;

public class DataSetTester {

public void main(String[] args){

DataSet Tester;

Tester = new DataSet();

Scanner scan = new Scanner(System.in);

System.out.println("Enter values, enter Q to finish");

value = scan.nextDouble();

while (value !=-1){

sum =+ value;

}

}

System.out.println("The Range is: " + Tester.getAverage());

Reference no: EM132211343

Questions Cloud

Displays the number of integers in the file : The program should loop through all integers between the low and high values. The loop should include the low and high integers.
What motivates company to develop cross-border alliance : What motivates a company to develop a cross-border alliance?
Find the correct value of coefficient of rank correlation : The coefficient of correlation of 12 pairs of observation was found to be 0.62 It was later discovered that the value of difference between the ranks.
What are main advantages and disadvantages of diversity : What are the main advantages and disadvantages of diversity and how can you optimize them? How diverse is your team? Be specific
Write a program that reads a set of floating-point values : Write a program that reads a set of floating-point values. Ask the user to enter the values (prompting only a single time for the values), then print.
Family meetings and meeting of family council : Discuss differences between shareholders’ meeting, family meetings and meeting of family council?
Write a program that reads a file name from a dialog box : Write a program that reads a file name from a dialog box. You should expect that the file name has one. (dot) character in it, separating the file name.
The student may emphasize changes in their code of ethics : The student may emphasize changes in their code of ethics over the years if any and how it has impacted aspects of their life.
Write a program that reads a floating-point number : Write a program that reads a floating-point number and prints "zero" if the number is zero. Otherwise print "positive" or "negative".

Reviews

Write a Review

Computer Engineering Questions & Answers

  Calculate the lower and the upper quartiles for the data

Calculate the lower and the upper quartiles for the data. Hence, calculate the inner and outer fences to draw a box and whisker plot

  Write code for the given functions

Write code for the following functions. Function void clear(Stack &s) deletes all entries and returns s as an empty Stack.

  Transmitting image through raster scan

If we were to transmit this image utilizing the raster scan order, after 15 seconds how many rows of image will the user have received? To what fraction of the image does this correspond?

  Manage the information of employees in a company

You will have an array of Employee structs to keep the information of all employees. The employees.txt file may be in different size.

  Summarize utilitarianism as a moral theory

Summarize utilitarianism as a moral theory. b.) Then present a case that provides an example of how a utilitarian might reason when deciding what to do in a particular situation.

  This is a term long project and has 4 phases in phase 4

you have been hired as cio for a small independent auto-parts store - northwest georgia auto parts. the store has

  Create a set of use cases for accompanying dentist system

Create a set of use cases for the accompanying dentist office system, but do not bother to identify the steps within each use case.

  What is the throughput per station for a 1-km

A simple medium access control protocol would be to use a fixed assignment time division multiplexing (TDM) scheme.

  Determine the expected number of die rolls until a coin flip

Explain how to use die rolls to generate unbiased coin flips, and determine the expected number of die rolls until a coin flip is generated.

  What are four important tactical tasks for a negotiator

What are four important tactical tasks for a negotiator in a distributive situation to consider? Discuss one instance where you have been involved.

  Write a paper explaining the business uses of cloud

write a paper explaining the business uses of cloud computing and web 2.0. your paper should be 3-5 pages in length

  Make a list of your favorite fruits

Make a list of your favorite fruits, and then write a series of independent if statements that check for certain fruits in your list.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd