SlideShare une entreprise Scribd logo
1  sur  14
Use the following data set that compares age to average "years
left to live" to answer the following questions.
Age 10 20 30 40 50 60 70 80 90 100
Years to live 59.2 49.6 40.7 31.9 24.0 17.2 11.6 7.2 4 .4 2.8
a) Show the scatterplot for this data with the least squares
regression line. Find R^2. How much of the variation is
explained by the regression line?
b) Experiment with the non-linear regressions available on the
calculator. Which seem to fit? Show the scatterplot with three
different regression curves from the calculator. Label each
equation, as well as the applicable R^2.
c) Choose a regression equation to predict how many "years
left" a person has if he is now 101 years old. Can he count on
celebrating Christmas 2015?
InfoTest.javaInfoTest.javapackage assignment1;
importstatic org.junit.Assert.*;
import org.junit.Test;
publicclassInfoTest{
@Test
publicvoid testInfo(){
Info tempInfo =newInfo();
assertNotNull(tempInfo.tmp);
}
@Test
publicvoid testInsert(){
Info tempInfo =newInfo();
// Insert into an empty list
tempInfo.insert(30);
assertEquals(30, tempInfo.get(0));
// Insert an item to be placed at the beginning of the list
tempInfo.insert(4);
assertEquals(4, tempInfo.get(0));
assertEquals(30, tempInfo.get(1));
// Insert an item to be placed at the end of the list
tempInfo.insert(20);
assertEquals(20, tempInfo.get(1));
assertEquals(30, tempInfo.get(2));
// Insert an which already exists
tempInfo.insert(20);
assertEquals(4, tempInfo.get(0));
assertEquals(20, tempInfo.get(1));
assertEquals(30, tempInfo.get(2));
}
@Test
publicvoid testDelete(){
Info tempInfo =newInfo();
tempInfo.insert(15);
tempInfo.insert(5);
tempInfo.insert(10);
// delete from the middle
tempInfo.delete(10);
assertEquals(5, tempInfo.get(0));
assertEquals(15, tempInfo.get(1));
// delete from the beginning
tempInfo.insert(10);
tempInfo.delete(5);
assertEquals(10, tempInfo.get(0));
assertEquals(15, tempInfo.get(1));
// delete from the end
tempInfo.insert(5);
tempInfo.delete(15);
assertEquals(5, tempInfo.get(0));
assertEquals(10, tempInfo.get(1));
// delete something that does not exist
tempInfo.insert(15);
tempInfo.delete(7);
assertEquals(5, tempInfo.get(0));
assertEquals(10, tempInfo.get(1));
assertEquals(15, tempInfo.get(1));
}
@Test
publicvoid testGet(){
Info tempInfo =newInfo();
tempInfo.insert(15);
tempInfo.insert(5);
tempInfo.insert(10);
// get items at the beginning, middle, and end of the list
assertEquals(5, tempInfo.get(0));
assertEquals(10, tempInfo.get(1));
assertEquals(15, tempInfo.get(2));
// get an unexisting item
assertNull(tempInfo.get(3));
}
@Test
publicvoid testCount(){
Info tempInfo =newInfo();
// count the items in an empty list
assertEquals(0, tempInfo.count());
// count the items in a list with 1 item
tempInfo.insert(15);
assertEquals(1, tempInfo.count());
// count the items in a list with 2 items
tempInfo.insert(5);
assertEquals(2, tempInfo.count());
// count the items in a list with 3 items
tempInfo.insert(10);
assertEquals(3, tempInfo.count());
}
@Test
publicvoid testCopy(){
Info tempInfo =newInfo();
tempInfo.insert(15);
tempInfo.insert(5);
tempInfo.insert(10);
tempInfo.insert(17);
tempInfo.insert(50);
tempInfo.insert(3);
tempInfo.insert(7);
tempInfo.insert(11);
tempInfo.insert(23);
// copy a set of items from the list
Info infoCopy = tempInfo.copy(3,6);
assertEquals(10, infoCopy.get(0));
assertEquals(11, infoCopy.get(1));
assertEquals(15, infoCopy.get(2));
assertNull(infoCopy.get(3));
// copy only 1 item
infoCopy = tempInfo.copy(7,8);
assertEquals(23, infoCopy.get(7));
// copy out of bounds
infoCopy = tempInfo.copy(10,12);
assertNull(infoCopy);
}
@Test
publicvoid testMerge(){
/*
* merge two lists with no duplicates
*/
Info tempInfo =newInfo();
tempInfo.insert(15);
tempInfo.insert(5);
tempInfo.insert(10);
Info merge =newInfo();
merge.insert(7);
merge.insert(1);
merge.insert(23);
merge.insert(9);
tempInfo.merge(merge);
assertEquals(7, tempInfo.count());
assertEquals(1, tempInfo.get(0));
assertEquals(5, tempInfo.get(1));
assertEquals(7, tempInfo.get(2));
assertEquals(9, tempInfo.get(3));
assertEquals(10, tempInfo.get(4));
assertEquals(15, tempInfo.get(5));
assertEquals(23, tempInfo.get(6));
/*
* merge lists with 2 duplicates
*/
tempInfo =newInfo();
tempInfo.insert(15);
tempInfo.insert(5);
tempInfo.insert(10);
merge =newInfo();
merge.insert(5);
merge.insert(15);
merge.insert(9);
tempInfo.merge(merge);
assertEquals(4, tempInfo.count());
assertEquals(5, tempInfo.get(0));
assertEquals(9, tempInfo.get(1));
assertEquals(10, tempInfo.get(2));
assertEquals(15, tempInfo.get(3));
/*
* merge the list with an empty list
*/
tempInfo =newInfo();
tempInfo.insert(15);
tempInfo.insert(5);
tempInfo.insert(10);
merge =newInfo();
tempInfo.merge(merge);
assertEquals(3, tempInfo.count());
assertEquals(5, tempInfo.get(0));
assertEquals(10, tempInfo.get(1));
assertEquals(15, tempInfo.get(2));
}
@Test
publicvoid testIndexOf(){
Info tempInfo =newInfo();
tempInfo.insert(5);
// get the index of the element in a list with one item
assertEquals(0, tempInfo.indexOf(5));
tempInfo.insert(15);
tempInfo.insert(10);
// get the index of the element in the middle
assertEquals(1, tempInfo.indexOf(10));
// get the index of an unexisting object
assertEquals(-1, tempInfo.indexOf(20));
}
@Test
publicvoid testToArray(){
Info tempInfo =newInfo();
// get the array of an empty object
Object[] infoArray = tempInfo.toArray();
assertTrue(infoArray.length ==0);
tempInfo.insert(15);
tempInfo.insert(5);
tempInfo.insert(10);
tempInfo.insert(17);
tempInfo.insert(50);
tempInfo.insert(3);
tempInfo.insert(7);
tempInfo.insert(11);
tempInfo.insert(23);
tempInfo.insert(61);
// get the array with several elements
infoArray = tempInfo.toArray();
for(int i =0; i <10; i++){
assertTrue(infoArray[i]== tempInfo.get(i));
}
}
}
Info.javaInfo.javapackage info;
publicclassInfo{
/**
* Class Info is a implementation for a collection of Compara
ble objects.
* All values are kept in ascending order and have a position
where 0 is the position of the first object in the collection.
* There is no maximum size for the collection.
*/
// Temporary holder for the collection. To be updated in final i
mplementation.
Comparable tmp;
/**
* Creates an empty Info object to hold Comparable objects.
*/
Info(){
tmp =null;
}
/**
* Inserts the parameter into the Info object so the values in t
he Info object are in ascending order.
* If the value is already in the array, do not insert it.
* @param obj the Comparable object to insert
*/
void insert (Comparable obj){
}
/**
* Delete the parameter object if it is in the Info object.
* @param obj the Comparable object to delete
*/
void delete (Comparable obj){
}
/**
* Return the Comparable object at the position given. If the
parameter position is out of bounds, return null.
* @param x the position of the Comparable object in the Inf
o object to access
* @return object found in Info object
*/
Object get (int x){
returnnull;
}
/**
* Return the number of Comparable objects are in the Info o
bject
* @return count of Comparable objects
*/
int count (){
returnInteger.MIN_VALUE;
}
/**
* Return an Info object that is a copy of the contents from th
e first parameter position to the last parameter
* position. If the bounds given are out of bounds, return nul
l.
* @param x first position to copy
* @param y last position to copy
* @return new Info object
*/
Info copy (int x,int y){
returnnull;
}
/**
* Merge the current Info object with the parameter Info obje
ct.
* The results should be a new Info object in ascending order
with no duplicates.
* @param list Info object to merge with the current Info obj
ect
* @return new Info object with merged values
*/
Info merge (Info list){
returnnull;
}
/**
* Return the position of the parameter in the Info object.
* If the Comparable object is not in the Info object, return -
1.
* @param obj Comparable object to search for
* @return integer position of parameter in Info object
*/
int indexOf (Comparable obj){
returnInteger.MAX_VALUE;
}
/**
* Copies the contents of the collection Info object to an arra
y. The array contains the
* same number of elements as the original collection and obj
ects are in the same order.
* @return array of Comparable objects
*/
Object[] toArray(){
returnnull;
}
}
CSE360 Assignment 5(2).docx
CSE360 Fall 2015
Assignment 5 Due Nov 6 3PM
This is an assignment in writing and testing unit level code.
You may work solo or in a pair. Be sure to put both your names
on the completed work (all files).
In assignment 1, you wrote the Junit cases for the class Info. It
is now time to implement the code for Info and test it.
<<interface>>
Comparable
Item
Info
· str:String
· val:int
· list:Node
· numNodes:int
+ compareTo(Comparable): int
+ compareTo(Item):int
+ toString():String
+ Info()
+ insert (Item): void
+ delete (Item): void
+ get (int): Item
+ count(): int
+ copy(int, int): Info
+ merge(Info): Info
+ indexOf(Item): int
+ toString(): String
· Node
· data: Item
· next: Node
+ Node (Item)
The diagram above shows that an Item consists of two data
attributes: a String and an integer: An Info contains a Node and
an integer. The Node class is implemented as an internal or
private class in Info. This is shown above by the circle with the
lines.
Note that the toArray method has now been replaced by the
toString method.(In the template you have toArray, change it to
toString now)
Info must be implemented as a singly linked list using the
internal Node class. The variable list is a reference to the first
node in the list and numNodes hold the current count of the
nodes. Using another implementation including the Java
Collections Framework is not acceptable.
Also, all code must meet the style and documentation
requirements covered in class.
Test your code using your Junit tests. Make
changes/improvements to the tests as needed.
Submit your InfoTest.java, Info.java and Item.java files on
Blackboard (Assignment 5) by the deadline. Late submittals are
penalized. (InfoTest.java and Info.java are given, you just need
to modify it, For the Item.java you need to create your own
version)
Use the following data set that compares age to average years lef.docx

Contenu connexe

Similaire à Use the following data set that compares age to average years lef.docx

I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
fantoosh1
 
Required to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docxRequired to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docx
debishakespeare
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
freddysarabia1
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structures
Mohd Arif
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
ravikapoorindia
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
mail931892
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
info114
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10
Vince Vo
 

Similaire à Use the following data set that compares age to average years lef.docx (20)

I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
 
Required to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docxRequired to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docx
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Chapter2
Chapter2Chapter2
Chapter2
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structures
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Visual basic bt0082
Visual basic  bt0082Visual basic  bt0082
Visual basic bt0082
 
Data structures KTU chapter2.PPT
Data structures KTU chapter2.PPTData structures KTU chapter2.PPT
Data structures KTU chapter2.PPT
 
DS UNIT3_LINKED LISTS.docx
DS UNIT3_LINKED LISTS.docxDS UNIT3_LINKED LISTS.docx
DS UNIT3_LINKED LISTS.docx
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
Array
ArrayArray
Array
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10
 

Plus de dickonsondorris

Copyright © eContent Management Pty Ltd. Health Sociology Revi.docx
Copyright © eContent Management Pty Ltd. Health Sociology Revi.docxCopyright © eContent Management Pty Ltd. Health Sociology Revi.docx
Copyright © eContent Management Pty Ltd. Health Sociology Revi.docx
dickonsondorris
 
Copyright © Pearson Education 2010 Digital Tools in Toda.docx
Copyright © Pearson Education 2010 Digital Tools in Toda.docxCopyright © Pearson Education 2010 Digital Tools in Toda.docx
Copyright © Pearson Education 2010 Digital Tools in Toda.docx
dickonsondorris
 
Copyright © Jen-Wen Lin 2018 1 STA457 Time series .docx
Copyright © Jen-Wen Lin 2018   1 STA457 Time series .docxCopyright © Jen-Wen Lin 2018   1 STA457 Time series .docx
Copyright © Jen-Wen Lin 2018 1 STA457 Time series .docx
dickonsondorris
 
Copyright © John Wiley & Sons, Inc. All rights reserved..docx
Copyright © John Wiley & Sons, Inc. All rights reserved..docxCopyright © John Wiley & Sons, Inc. All rights reserved..docx
Copyright © John Wiley & Sons, Inc. All rights reserved..docx
dickonsondorris
 
Copyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docx
Copyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docxCopyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docx
Copyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docx
dickonsondorris
 
Copyright © Cengage Learning. All rights reserved. CHAPTE.docx
Copyright © Cengage Learning.  All rights reserved. CHAPTE.docxCopyright © Cengage Learning.  All rights reserved. CHAPTE.docx
Copyright © Cengage Learning. All rights reserved. CHAPTE.docx
dickonsondorris
 
Copyright © by Holt, Rinehart and Winston. All rights reserved.docx
Copyright © by Holt, Rinehart and Winston. All rights reserved.docxCopyright © by Holt, Rinehart and Winston. All rights reserved.docx
Copyright © by Holt, Rinehart and Winston. All rights reserved.docx
dickonsondorris
 
Copyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docx
Copyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docxCopyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docx
Copyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docx
dickonsondorris
 
Copyright © 2019, American Institute of Certified Public Accou.docx
Copyright © 2019, American Institute of Certified Public Accou.docxCopyright © 2019, American Institute of Certified Public Accou.docx
Copyright © 2019, American Institute of Certified Public Accou.docx
dickonsondorris
 
Copyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docx
Copyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docxCopyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docx
Copyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docx
dickonsondorris
 
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R  6.docxCopyright © 2018 Pearson Education, Inc. C H A P T E R  6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
dickonsondorris
 
Copyright © 2018 Capella University. Copy and distribution o.docx
Copyright © 2018 Capella University. Copy and distribution o.docxCopyright © 2018 Capella University. Copy and distribution o.docx
Copyright © 2018 Capella University. Copy and distribution o.docx
dickonsondorris
 
Copyright © 2018 Pearson Education, Inc.C H A P T E R 3.docx
Copyright © 2018 Pearson Education, Inc.C H A P T E R  3.docxCopyright © 2018 Pearson Education, Inc.C H A P T E R  3.docx
Copyright © 2018 Pearson Education, Inc.C H A P T E R 3.docx
dickonsondorris
 
Copyright © 2018 by Steven Levitsky and Daniel.docx
Copyright © 2018 by Steven Levitsky and Daniel.docxCopyright © 2018 by Steven Levitsky and Daniel.docx
Copyright © 2018 by Steven Levitsky and Daniel.docx
dickonsondorris
 
Copyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docx
Copyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docxCopyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docx
Copyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docx
dickonsondorris
 
Copyright © 2017 Wolters Kluwer Health Lippincott Williams.docx
Copyright © 2017 Wolters Kluwer Health  Lippincott Williams.docxCopyright © 2017 Wolters Kluwer Health  Lippincott Williams.docx
Copyright © 2017 Wolters Kluwer Health Lippincott Williams.docx
dickonsondorris
 
Copyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docx
Copyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docxCopyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docx
Copyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docx
dickonsondorris
 
Copyright © 2017 by University of Phoenix. All rights rese.docx
Copyright © 2017 by University of Phoenix. All rights rese.docxCopyright © 2017 by University of Phoenix. All rights rese.docx
Copyright © 2017 by University of Phoenix. All rights rese.docx
dickonsondorris
 
Copyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docx
Copyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docxCopyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docx
Copyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docx
dickonsondorris
 
Copyright © 2016 Pearson Education, Inc. .docx
Copyright © 2016 Pearson Education, Inc.                    .docxCopyright © 2016 Pearson Education, Inc.                    .docx
Copyright © 2016 Pearson Education, Inc. .docx
dickonsondorris
 

Plus de dickonsondorris (20)

Copyright © eContent Management Pty Ltd. Health Sociology Revi.docx
Copyright © eContent Management Pty Ltd. Health Sociology Revi.docxCopyright © eContent Management Pty Ltd. Health Sociology Revi.docx
Copyright © eContent Management Pty Ltd. Health Sociology Revi.docx
 
Copyright © Pearson Education 2010 Digital Tools in Toda.docx
Copyright © Pearson Education 2010 Digital Tools in Toda.docxCopyright © Pearson Education 2010 Digital Tools in Toda.docx
Copyright © Pearson Education 2010 Digital Tools in Toda.docx
 
Copyright © Jen-Wen Lin 2018 1 STA457 Time series .docx
Copyright © Jen-Wen Lin 2018   1 STA457 Time series .docxCopyright © Jen-Wen Lin 2018   1 STA457 Time series .docx
Copyright © Jen-Wen Lin 2018 1 STA457 Time series .docx
 
Copyright © John Wiley & Sons, Inc. All rights reserved..docx
Copyright © John Wiley & Sons, Inc. All rights reserved..docxCopyright © John Wiley & Sons, Inc. All rights reserved..docx
Copyright © John Wiley & Sons, Inc. All rights reserved..docx
 
Copyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docx
Copyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docxCopyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docx
Copyright © by The McGraw-Hill Companies, Inc. The Aztec Accou.docx
 
Copyright © Cengage Learning. All rights reserved. CHAPTE.docx
Copyright © Cengage Learning.  All rights reserved. CHAPTE.docxCopyright © Cengage Learning.  All rights reserved. CHAPTE.docx
Copyright © Cengage Learning. All rights reserved. CHAPTE.docx
 
Copyright © by Holt, Rinehart and Winston. All rights reserved.docx
Copyright © by Holt, Rinehart and Winston. All rights reserved.docxCopyright © by Holt, Rinehart and Winston. All rights reserved.docx
Copyright © by Holt, Rinehart and Winston. All rights reserved.docx
 
Copyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docx
Copyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docxCopyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docx
Copyright © 2020 by Jones & Bartlett Learning, LLC, an Ascend .docx
 
Copyright © 2019, American Institute of Certified Public Accou.docx
Copyright © 2019, American Institute of Certified Public Accou.docxCopyright © 2019, American Institute of Certified Public Accou.docx
Copyright © 2019, American Institute of Certified Public Accou.docx
 
Copyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docx
Copyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docxCopyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docx
Copyright © 2018 Pearson Education, Inc. All Rights ReservedChild .docx
 
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R  6.docxCopyright © 2018 Pearson Education, Inc. C H A P T E R  6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
 
Copyright © 2018 Capella University. Copy and distribution o.docx
Copyright © 2018 Capella University. Copy and distribution o.docxCopyright © 2018 Capella University. Copy and distribution o.docx
Copyright © 2018 Capella University. Copy and distribution o.docx
 
Copyright © 2018 Pearson Education, Inc.C H A P T E R 3.docx
Copyright © 2018 Pearson Education, Inc.C H A P T E R  3.docxCopyright © 2018 Pearson Education, Inc.C H A P T E R  3.docx
Copyright © 2018 Pearson Education, Inc.C H A P T E R 3.docx
 
Copyright © 2018 by Steven Levitsky and Daniel.docx
Copyright © 2018 by Steven Levitsky and Daniel.docxCopyright © 2018 by Steven Levitsky and Daniel.docx
Copyright © 2018 by Steven Levitsky and Daniel.docx
 
Copyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docx
Copyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docxCopyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docx
Copyright © 2017, 2014, 2011 Pearson Education, Inc. All Right.docx
 
Copyright © 2017 Wolters Kluwer Health Lippincott Williams.docx
Copyright © 2017 Wolters Kluwer Health  Lippincott Williams.docxCopyright © 2017 Wolters Kluwer Health  Lippincott Williams.docx
Copyright © 2017 Wolters Kluwer Health Lippincott Williams.docx
 
Copyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docx
Copyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docxCopyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docx
Copyright © 2016, 2013, 2010 Pearson Education, Inc. All Right.docx
 
Copyright © 2017 by University of Phoenix. All rights rese.docx
Copyright © 2017 by University of Phoenix. All rights rese.docxCopyright © 2017 by University of Phoenix. All rights rese.docx
Copyright © 2017 by University of Phoenix. All rights rese.docx
 
Copyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docx
Copyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docxCopyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docx
Copyright © 2016 John Wiley & Sons, Inc.Copyright © 20.docx
 
Copyright © 2016 Pearson Education, Inc. .docx
Copyright © 2016 Pearson Education, Inc.                    .docxCopyright © 2016 Pearson Education, Inc.                    .docx
Copyright © 2016 Pearson Education, Inc. .docx
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Dernier (20)

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 

Use the following data set that compares age to average years lef.docx

  • 1. Use the following data set that compares age to average "years left to live" to answer the following questions. Age 10 20 30 40 50 60 70 80 90 100 Years to live 59.2 49.6 40.7 31.9 24.0 17.2 11.6 7.2 4 .4 2.8 a) Show the scatterplot for this data with the least squares regression line. Find R^2. How much of the variation is explained by the regression line? b) Experiment with the non-linear regressions available on the calculator. Which seem to fit? Show the scatterplot with three different regression curves from the calculator. Label each equation, as well as the applicable R^2. c) Choose a regression equation to predict how many "years left" a person has if he is now 101 years old. Can he count on celebrating Christmas 2015? InfoTest.javaInfoTest.javapackage assignment1; importstatic org.junit.Assert.*; import org.junit.Test; publicclassInfoTest{ @Test publicvoid testInfo(){ Info tempInfo =newInfo(); assertNotNull(tempInfo.tmp); } @Test publicvoid testInsert(){ Info tempInfo =newInfo();
  • 2. // Insert into an empty list tempInfo.insert(30); assertEquals(30, tempInfo.get(0)); // Insert an item to be placed at the beginning of the list tempInfo.insert(4); assertEquals(4, tempInfo.get(0)); assertEquals(30, tempInfo.get(1)); // Insert an item to be placed at the end of the list tempInfo.insert(20); assertEquals(20, tempInfo.get(1)); assertEquals(30, tempInfo.get(2)); // Insert an which already exists tempInfo.insert(20); assertEquals(4, tempInfo.get(0)); assertEquals(20, tempInfo.get(1)); assertEquals(30, tempInfo.get(2)); } @Test publicvoid testDelete(){ Info tempInfo =newInfo(); tempInfo.insert(15); tempInfo.insert(5); tempInfo.insert(10); // delete from the middle tempInfo.delete(10); assertEquals(5, tempInfo.get(0)); assertEquals(15, tempInfo.get(1)); // delete from the beginning tempInfo.insert(10);
  • 3. tempInfo.delete(5); assertEquals(10, tempInfo.get(0)); assertEquals(15, tempInfo.get(1)); // delete from the end tempInfo.insert(5); tempInfo.delete(15); assertEquals(5, tempInfo.get(0)); assertEquals(10, tempInfo.get(1)); // delete something that does not exist tempInfo.insert(15); tempInfo.delete(7); assertEquals(5, tempInfo.get(0)); assertEquals(10, tempInfo.get(1)); assertEquals(15, tempInfo.get(1)); } @Test publicvoid testGet(){ Info tempInfo =newInfo(); tempInfo.insert(15); tempInfo.insert(5); tempInfo.insert(10); // get items at the beginning, middle, and end of the list assertEquals(5, tempInfo.get(0)); assertEquals(10, tempInfo.get(1)); assertEquals(15, tempInfo.get(2)); // get an unexisting item assertNull(tempInfo.get(3)); } @Test
  • 4. publicvoid testCount(){ Info tempInfo =newInfo(); // count the items in an empty list assertEquals(0, tempInfo.count()); // count the items in a list with 1 item tempInfo.insert(15); assertEquals(1, tempInfo.count()); // count the items in a list with 2 items tempInfo.insert(5); assertEquals(2, tempInfo.count()); // count the items in a list with 3 items tempInfo.insert(10); assertEquals(3, tempInfo.count()); } @Test publicvoid testCopy(){ Info tempInfo =newInfo(); tempInfo.insert(15); tempInfo.insert(5); tempInfo.insert(10); tempInfo.insert(17); tempInfo.insert(50); tempInfo.insert(3); tempInfo.insert(7); tempInfo.insert(11); tempInfo.insert(23); // copy a set of items from the list Info infoCopy = tempInfo.copy(3,6); assertEquals(10, infoCopy.get(0));
  • 5. assertEquals(11, infoCopy.get(1)); assertEquals(15, infoCopy.get(2)); assertNull(infoCopy.get(3)); // copy only 1 item infoCopy = tempInfo.copy(7,8); assertEquals(23, infoCopy.get(7)); // copy out of bounds infoCopy = tempInfo.copy(10,12); assertNull(infoCopy); } @Test publicvoid testMerge(){ /* * merge two lists with no duplicates */ Info tempInfo =newInfo(); tempInfo.insert(15); tempInfo.insert(5); tempInfo.insert(10); Info merge =newInfo(); merge.insert(7); merge.insert(1); merge.insert(23); merge.insert(9); tempInfo.merge(merge); assertEquals(7, tempInfo.count()); assertEquals(1, tempInfo.get(0)); assertEquals(5, tempInfo.get(1)); assertEquals(7, tempInfo.get(2)); assertEquals(9, tempInfo.get(3));
  • 6. assertEquals(10, tempInfo.get(4)); assertEquals(15, tempInfo.get(5)); assertEquals(23, tempInfo.get(6)); /* * merge lists with 2 duplicates */ tempInfo =newInfo(); tempInfo.insert(15); tempInfo.insert(5); tempInfo.insert(10); merge =newInfo(); merge.insert(5); merge.insert(15); merge.insert(9); tempInfo.merge(merge); assertEquals(4, tempInfo.count()); assertEquals(5, tempInfo.get(0)); assertEquals(9, tempInfo.get(1)); assertEquals(10, tempInfo.get(2)); assertEquals(15, tempInfo.get(3)); /* * merge the list with an empty list */ tempInfo =newInfo(); tempInfo.insert(15); tempInfo.insert(5); tempInfo.insert(10); merge =newInfo(); tempInfo.merge(merge); assertEquals(3, tempInfo.count());
  • 7. assertEquals(5, tempInfo.get(0)); assertEquals(10, tempInfo.get(1)); assertEquals(15, tempInfo.get(2)); } @Test publicvoid testIndexOf(){ Info tempInfo =newInfo(); tempInfo.insert(5); // get the index of the element in a list with one item assertEquals(0, tempInfo.indexOf(5)); tempInfo.insert(15); tempInfo.insert(10); // get the index of the element in the middle assertEquals(1, tempInfo.indexOf(10)); // get the index of an unexisting object assertEquals(-1, tempInfo.indexOf(20)); } @Test publicvoid testToArray(){ Info tempInfo =newInfo(); // get the array of an empty object Object[] infoArray = tempInfo.toArray(); assertTrue(infoArray.length ==0); tempInfo.insert(15); tempInfo.insert(5); tempInfo.insert(10); tempInfo.insert(17); tempInfo.insert(50);
  • 8. tempInfo.insert(3); tempInfo.insert(7); tempInfo.insert(11); tempInfo.insert(23); tempInfo.insert(61); // get the array with several elements infoArray = tempInfo.toArray(); for(int i =0; i <10; i++){ assertTrue(infoArray[i]== tempInfo.get(i)); } } } Info.javaInfo.javapackage info; publicclassInfo{ /** * Class Info is a implementation for a collection of Compara ble objects. * All values are kept in ascending order and have a position where 0 is the position of the first object in the collection. * There is no maximum size for the collection. */ // Temporary holder for the collection. To be updated in final i mplementation. Comparable tmp; /** * Creates an empty Info object to hold Comparable objects. */ Info(){
  • 9. tmp =null; } /** * Inserts the parameter into the Info object so the values in t he Info object are in ascending order. * If the value is already in the array, do not insert it. * @param obj the Comparable object to insert */ void insert (Comparable obj){ } /** * Delete the parameter object if it is in the Info object. * @param obj the Comparable object to delete */ void delete (Comparable obj){ } /** * Return the Comparable object at the position given. If the parameter position is out of bounds, return null. * @param x the position of the Comparable object in the Inf o object to access * @return object found in Info object */ Object get (int x){ returnnull; } /** * Return the number of Comparable objects are in the Info o bject * @return count of Comparable objects */
  • 10. int count (){ returnInteger.MIN_VALUE; } /** * Return an Info object that is a copy of the contents from th e first parameter position to the last parameter * position. If the bounds given are out of bounds, return nul l. * @param x first position to copy * @param y last position to copy * @return new Info object */ Info copy (int x,int y){ returnnull; } /** * Merge the current Info object with the parameter Info obje ct. * The results should be a new Info object in ascending order with no duplicates. * @param list Info object to merge with the current Info obj ect * @return new Info object with merged values */ Info merge (Info list){ returnnull; } /** * Return the position of the parameter in the Info object. * If the Comparable object is not in the Info object, return - 1. * @param obj Comparable object to search for * @return integer position of parameter in Info object
  • 11. */ int indexOf (Comparable obj){ returnInteger.MAX_VALUE; } /** * Copies the contents of the collection Info object to an arra y. The array contains the * same number of elements as the original collection and obj ects are in the same order. * @return array of Comparable objects */ Object[] toArray(){ returnnull; } } CSE360 Assignment 5(2).docx CSE360 Fall 2015 Assignment 5 Due Nov 6 3PM This is an assignment in writing and testing unit level code. You may work solo or in a pair. Be sure to put both your names on the completed work (all files). In assignment 1, you wrote the Junit cases for the class Info. It is now time to implement the code for Info and test it. <<interface>> Comparable Item Info
  • 12. · str:String · val:int · list:Node · numNodes:int + compareTo(Comparable): int + compareTo(Item):int + toString():String + Info() + insert (Item): void + delete (Item): void + get (int): Item + count(): int + copy(int, int): Info + merge(Info): Info + indexOf(Item): int + toString(): String · Node · data: Item · next: Node
  • 13. + Node (Item) The diagram above shows that an Item consists of two data attributes: a String and an integer: An Info contains a Node and an integer. The Node class is implemented as an internal or private class in Info. This is shown above by the circle with the lines. Note that the toArray method has now been replaced by the toString method.(In the template you have toArray, change it to toString now) Info must be implemented as a singly linked list using the internal Node class. The variable list is a reference to the first node in the list and numNodes hold the current count of the nodes. Using another implementation including the Java Collections Framework is not acceptable. Also, all code must meet the style and documentation requirements covered in class. Test your code using your Junit tests. Make changes/improvements to the tests as needed. Submit your InfoTest.java, Info.java and Item.java files on Blackboard (Assignment 5) by the deadline. Late submittals are penalized. (InfoTest.java and Info.java are given, you just need to modify it, For the Item.java you need to create your own version)