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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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