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

  Plan a decision tree for this situation

Premium Airlines has recently offered to settle claims for a class-action suit that was originated for alleged price fixing of tickets. The proposed settlement is stated as follows. Draw a decision tree for this situation.

  What is oriented programming and object-oriented design

Find out resources on Visual Basic. Select your favorite three and explain what they have to offer. Also discuss the differences between Object-Oriented Programming (OOP) and Object-Oriented Design (OOD).

  What kind of responses must p and g make to enable

What are the implications of these changes for managing P&G human capital?

  What is the clock speed of this processor

What is the clock speed of this processor ?What is the throughput of this processor (in billion instructions per second)?

  Explaining the role of cio

Assess the role of CIO within any health care organization and explain the key characteristics a CIO would require to possess to be effective in that position.

  What is the expected value of the jaccard similarity

Suppose s1 and s2 are randomly selected subsets from a universal set with n items. What is the expected value of the Jaccard similarity J(s1, s2)?

  What are the most important factors to consider

How will implementing these controls affect the CIA (confidentiality, integrity, availability) triad of your enterprise?

  How can a company use change management to minimize

how can a company use change management to minimize resistance and maximize the acceptance of change in business and

  Choose a social network site and research its security

select a social network site and research its security features. are they sufficient? should they be stronger? what

  Create a boxplot of high temperature using month

Create a boxplot of ‘high temperature' using ‘month' as a factor variable.

  Compute the definite integral from 0 to 10 of the function

Write a MATLAB function that will compute the definite integral from 0 to 10 of the function y = 2x3.

  Define governance principles for cloud-based solutions

The chief information officer (CIO) is very pleased with all of your efforts to adopt cloud-based services and wants to ensure the data is secure.

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