Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have the integer = min and max working but how do I print them? Or how do I make my integer max into an

I have the integer = min and max working but how do I print them? Or how do I make my "integer max" into an actual int so I can be able to find the range and print it?

/** * Kyle Donohue * This program will have the user input the number of objects into a LinkedList * April 17th, 2018 */ import java.util.Scanner; import java.util.LinkedList; import java.util.ListIterator; import java.util.Random; import java.util.Collections;

public class hw2 { public static void main(String[] args) { LinkedList list=new LinkedList(); Scanner in= new Scanner(System.in); System.out.print("Enter the number of objects: "); int n= in.nextInt(); Random r= new Random(); int random; for(int i=0;i iterator= list.listIterator(); integer b; int count=0; do{ b=iterator.next(); System.out.printf("%3d%9d%10d ", iterator.nextIndex(), b.getoriginal(), b.getrandom()); count++; }while(iterator.hasNext()); int sum=0; float mean; random=r.nextInt(list.size()); iterator= list.listIterator(); do{ b=iterator.next(); sum=sum+b.getrandom(); integer min = list.get(0); integer max = list.get(list.size()-1); }while(iterator.hasNext()); System.out.println(" Sum = "+sum); mean=sum/list.size(); System.out.println("Mean = "+mean); System.out.println("Range = " + ????); int med; if(list.size()%2==0){ med=list.size()/2 -1; }else{ med=list.size()/2; } System.out.println("Median= "+list.get(med).getrandom()); } }

*******************************

/* * Kyle Donohue * hw * * */ import java.util.Comparator; import java.util.List; public class integer implements Comparable{ int random; int original;

public integer(int r,int o) { random=r; original=o; } public int getoriginal(){ return original; }

public int getrandom(){ return random; } @Override public int compareTo(integer a){ if(a.random==this.random){ return 0; }else{ if(this.random>a.random){ return 1; }else{ return -1; } } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

=+management system of the MNE?

Answered: 1 week ago