Write an abstract Student class that stores a students name and all.docx

A

Write an abstract Student class that stores a students name and all

Write an abstract Student class that stores a student's name
and all of their grades for a course. There is no limit on the
number of graded assignments a course may have. Grades for a
course may be characters, integers, doubles, or strings (i.e. a
professor may decide to give grades in terms of A, B, C, etc., as
90, 93, 81, etc., as 81.4, 82.1, 95.4, etc., or as "acceptable",
"excellent", "poor", etc.) Whatever data type is used for the
grades in a course will be the same for all assignments in that
course. In other words, if one grade in a course is a character,
they will all be characters - it's not possible for one assignment
to be given a letter grade and another an integer grade. The
class should provide methods to add a grade, and to retrieve a
specific grade (for example, retrieving the student's score on
the third assignment). Remember that this is an abstract class -
you need to provide the class's data fields and the method
signatures, but not the implementations for the methods. Write
a program that adds one million numbers to the beginning of an
ArrayList and a Linked List. Time how long this takes in
seconds. Which one is faster? Why? (Provide a detailed
explanation of why the faster one is faster as a comment in your
code.) Write a program that adds one million numbers to an
ArrayList and a LinkedList and then remove these numbers one
at a time from the end of the list. Time how long this takes in
seconds. Which one is faster? Why? (Provide a detailed
explanation of why the faster one is faster as a comment in your
code.)
Solution
Problem 2:
import java.util.ArrayList;
public abstract class Student<T>{
String name;
ArrayList<T> grades;
public Student() {
grades = new ArrayList<T>();
}
abstract void addGrade(T grade);
abstract T addGrade(int assignment);
}
Problem 3:
import java.util.ArrayList;
import java.util.LinkedList;
public abstract class Student<T>{
public static void main(String args[]) {
ArrayList<Integer> al = new ArrayList<Integer>();
LinkedList<Integer> ll = new LinkedList<Integer>();
long startTime, stopTime, elapsedTime;
startTime = System.currentTimeMillis();
for(int i = 1; i <= 1000000; i++){
al.add(0, i);
}
stopTime = System.currentTimeMillis();
elapsedTime = stopTime - startTime;
System.out.println("In case of ArrayList, time: " +
elapsedTime);
startTime = System.currentTimeMillis();
for(int i = 1; i <= 1000000; i++){
ll.add(0, i);
}
stopTime = System.currentTimeMillis();
elapsedTime = stopTime - startTime;
System.out.println("In case of LinkedList, time: " +
elapsedTime);
// LinkedList is faster in adding 1 million elements at the
beginning, because in ArrayList, while adding any element in
the beginning, all the subsequent elements have to be moved 1
place forward
}
}
Problem 4:
import java.util.ArrayList;
import java.util.LinkedList;
public abstract class Student<T>{
public static void main(String args[]) {
ArrayList<Integer> al = new ArrayList<Integer>();
LinkedList<Integer> ll = new LinkedList<Integer>();
long startTime, stopTime, elapsedTime;
startTime = System.currentTimeMillis();
for(int i = 1; i <= 1000000; i++){
al.add(i);
}
stopTime = System.currentTimeMillis();
elapsedTime = stopTime - startTime;
System.out.println("In case of ArrayList, time: " +
elapsedTime);
startTime = System.currentTimeMillis();
for(int i = 1; i <= 1000000; i++){
ll.add(i);
}
stopTime = System.currentTimeMillis();
elapsedTime = stopTime - startTime;
System.out.println("In case of LinkedList, time: " +
elapsedTime);
// ArrayList is faster in adding 1 million elements at the
end, because in LinkedList, while adding any element in the
end, we have to traverse all the way to the end of the list
}
}

Recomendados

Two dimensional array von
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
1.1K views14 Folien
ch06.ppt von
ch06.pptch06.ppt
ch06.pptvalerie5142000
10 views68 Folien
ch06.ppt von
ch06.pptch06.ppt
ch06.pptchandrasekar529044
6 views68 Folien
ch06.ppt von
ch06.pptch06.ppt
ch06.pptansariparveen06
3 views68 Folien
array Details von
array Detailsarray Details
array Detailsshivas379526
1 view68 Folien
Learning ObjectivesAbstract ClassDynamic BindingReinforce Conc.docx von
Learning ObjectivesAbstract ClassDynamic BindingReinforce Conc.docxLearning ObjectivesAbstract ClassDynamic BindingReinforce Conc.docx
Learning ObjectivesAbstract ClassDynamic BindingReinforce Conc.docxjesseniasaddler
3 views10 Folien

Más contenido relacionado

Similar a Write an abstract Student class that stores a students name and all.docx

LectureNotes-05-DSA von
LectureNotes-05-DSALectureNotes-05-DSA
LectureNotes-05-DSAHaitham El-Ghareeb
1.3K views15 Folien
Templates von
TemplatesTemplates
TemplatesPranali Chaudhari
4.3K views29 Folien
Write a Java class Student with three fields- name- mark and maxscore.docx von
Write a Java class Student with three fields- name- mark and maxscore.docxWrite a Java class Student with three fields- name- mark and maxscore.docx
Write a Java class Student with three fields- name- mark and maxscore.docxlez31palka
3 views2 Folien
Assignment 9Write a generic class MyMathClass with at type para.pdf von
Assignment 9Write a generic class MyMathClass with at type para.pdfAssignment 9Write a generic class MyMathClass with at type para.pdf
Assignment 9Write a generic class MyMathClass with at type para.pdftsekar2004
2 views4 Folien
Computer programming 2 Lesson 13 von
Computer programming 2  Lesson 13Computer programming 2  Lesson 13
Computer programming 2 Lesson 13MLG College of Learning, Inc
139 views12 Folien
Lec 8 03_sept [compatibility mode] von
Lec 8 03_sept [compatibility mode]Lec 8 03_sept [compatibility mode]
Lec 8 03_sept [compatibility mode]Palak Sanghani
452 views35 Folien

Similar a Write an abstract Student class that stores a students name and all.docx(20)

Write a Java class Student with three fields- name- mark and maxscore.docx von lez31palka
Write a Java class Student with three fields- name- mark and maxscore.docxWrite a Java class Student with three fields- name- mark and maxscore.docx
Write a Java class Student with three fields- name- mark and maxscore.docx
lez31palka3 views
Assignment 9Write a generic class MyMathClass with at type para.pdf von tsekar2004
Assignment 9Write a generic class MyMathClass with at type para.pdfAssignment 9Write a generic class MyMathClass with at type para.pdf
Assignment 9Write a generic class MyMathClass with at type para.pdf
tsekar20042 views
Lec 8 03_sept [compatibility mode] von Palak Sanghani
Lec 8 03_sept [compatibility mode]Lec 8 03_sept [compatibility mode]
Lec 8 03_sept [compatibility mode]
Palak Sanghani452 views
This Is my code so far for the student class Need help .pdf von ajay1317
 This Is my code so far for the student class Need help .pdf This Is my code so far for the student class Need help .pdf
This Is my code so far for the student class Need help .pdf
ajay13176 views
A457405934_21789_26_2018_Inheritance.ppt von RithwikRanjan
A457405934_21789_26_2018_Inheritance.pptA457405934_21789_26_2018_Inheritance.ppt
A457405934_21789_26_2018_Inheritance.ppt
RithwikRanjan9 views
CSE 110 - ASSIGNMENT # 7 Due Wednesday April 13 by .docx von aryan532920
 CSE 110 - ASSIGNMENT # 7  Due Wednesday April 13 by .docx CSE 110 - ASSIGNMENT # 7  Due Wednesday April 13 by .docx
CSE 110 - ASSIGNMENT # 7 Due Wednesday April 13 by .docx
aryan5329205 views
The following classes are to complete the 'TODO' to fit the task- outp.pdf von JustinxitMillero
The following classes are to complete the 'TODO' to fit the task- outp.pdfThe following classes are to complete the 'TODO' to fit the task- outp.pdf
The following classes are to complete the 'TODO' to fit the task- outp.pdf
Micro project project co 3i von ARVIND SARDAR
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
ARVIND SARDAR121 views
How to write the last three methodsThanks. Work with a partner to c.pdf von barristeressaseren71
How to write the last three methodsThanks. Work with a partner to c.pdfHow to write the last three methodsThanks. Work with a partner to c.pdf
How to write the last three methodsThanks. Work with a partner to c.pdf
Chapter 6.6 von sotlsoc
Chapter 6.6Chapter 6.6
Chapter 6.6
sotlsoc338 views
Java assignment 1 von Daman Toor
Java assignment 1Java assignment 1
Java assignment 1
Daman Toor1.7K views
1-Determine the input- process and output requirements for the class N.docx von EvandWyBurgesss
1-Determine the input- process and output requirements for the class N.docx1-Determine the input- process and output requirements for the class N.docx
1-Determine the input- process and output requirements for the class N.docx
EvandWyBurgesss2 views
Object Oriented Solved Practice Programs C++ Exams von MuhammadTalha436
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
MuhammadTalha436189 views

Más de ajoy21

Please complete table with answers; BUT ALSO, show step by step all .docx von
Please complete table with answers; BUT ALSO, show step by step all .docxPlease complete table with answers; BUT ALSO, show step by step all .docx
Please complete table with answers; BUT ALSO, show step by step all .docxajoy21
14 views1 Folie
Please check the syllabus for the following essays(I am done with th.docx von
Please check the syllabus for the following essays(I am done with th.docxPlease check the syllabus for the following essays(I am done with th.docx
Please check the syllabus for the following essays(I am done with th.docxajoy21
9 views1 Folie
Please choose from the following companies for Assignment 21. H.docx von
Please choose from the following companies for Assignment 21. H.docxPlease choose from the following companies for Assignment 21. H.docx
Please choose from the following companies for Assignment 21. H.docxajoy21
3 views2 Folien
Please complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docx von
Please complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docxPlease complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docx
Please complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docxajoy21
3 views1 Folie
PLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docx von
PLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docxPLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docx
PLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docxajoy21
3 views2 Folien
Please complete ModuleWeek 4 assignment Research Paper Abstract .docx von
Please complete ModuleWeek 4 assignment Research Paper Abstract .docxPlease complete ModuleWeek 4 assignment Research Paper Abstract .docx
Please complete ModuleWeek 4 assignment Research Paper Abstract .docxajoy21
3 views1 Folie

Más de ajoy21(20)

Please complete table with answers; BUT ALSO, show step by step all .docx von ajoy21
Please complete table with answers; BUT ALSO, show step by step all .docxPlease complete table with answers; BUT ALSO, show step by step all .docx
Please complete table with answers; BUT ALSO, show step by step all .docx
ajoy2114 views
Please check the syllabus for the following essays(I am done with th.docx von ajoy21
Please check the syllabus for the following essays(I am done with th.docxPlease check the syllabus for the following essays(I am done with th.docx
Please check the syllabus for the following essays(I am done with th.docx
ajoy219 views
Please choose from the following companies for Assignment 21. H.docx von ajoy21
Please choose from the following companies for Assignment 21. H.docxPlease choose from the following companies for Assignment 21. H.docx
Please choose from the following companies for Assignment 21. H.docx
ajoy213 views
Please complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docx von ajoy21
Please complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docxPlease complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docx
Please complete ModuleWeek 4 Discussion Board Forum 3 with a repl.docx
ajoy213 views
PLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docx von ajoy21
PLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docxPLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docx
PLEASE AVOID CHANGING PRICE AFTER THE AGREEMENT IS SIGNED, THANK YOU.docx
ajoy213 views
Please complete ModuleWeek 4 assignment Research Paper Abstract .docx von ajoy21
Please complete ModuleWeek 4 assignment Research Paper Abstract .docxPlease complete ModuleWeek 4 assignment Research Paper Abstract .docx
Please complete ModuleWeek 4 assignment Research Paper Abstract .docx
ajoy213 views
Please complete outline to be used as guide for my assignment. For.docx von ajoy21
Please complete outline to be used as guide for my assignment. For.docxPlease complete outline to be used as guide for my assignment. For.docx
Please complete outline to be used as guide for my assignment. For.docx
ajoy213 views
Please complete the assignment listed below.Define and explain, us.docx von ajoy21
Please complete the assignment listed below.Define and explain, us.docxPlease complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docx
ajoy214 views
PLEASE COMPLETE ALL WORK IN DETAILDo work on a paper topic tha.docx von ajoy21
PLEASE COMPLETE ALL WORK IN DETAILDo work on a paper topic tha.docxPLEASE COMPLETE ALL WORK IN DETAILDo work on a paper topic tha.docx
PLEASE COMPLETE ALL WORK IN DETAILDo work on a paper topic tha.docx
ajoy212 views
Please complete in professional detail with professional responses f.docx von ajoy21
Please complete in professional detail with professional responses f.docxPlease complete in professional detail with professional responses f.docx
Please complete in professional detail with professional responses f.docx
ajoy212 views
PLEASE COMPLETE IN DETAIL AND PROVIDE SPECIFICS FOR AN INDIVIDUAL WH.docx von ajoy21
PLEASE COMPLETE IN DETAIL AND PROVIDE SPECIFICS FOR AN INDIVIDUAL WH.docxPLEASE COMPLETE IN DETAIL AND PROVIDE SPECIFICS FOR AN INDIVIDUAL WH.docx
PLEASE COMPLETE IN DETAIL AND PROVIDE SPECIFICS FOR AN INDIVIDUAL WH.docx
ajoy213 views
Please complete the below assignments, attached are pages from the t.docx von ajoy21
Please complete the below assignments, attached are pages from the t.docxPlease complete the below assignments, attached are pages from the t.docx
Please complete the below assignments, attached are pages from the t.docx
ajoy214 views
Please complete as two separate essay questions, in APA format.  No .docx von ajoy21
Please complete as two separate essay questions, in APA format.  No .docxPlease complete as two separate essay questions, in APA format.  No .docx
Please complete as two separate essay questions, in APA format.  No .docx
ajoy215 views
Please carefully check the due timeyou have 10+hours to finish thi.docx von ajoy21
Please carefully check the due timeyou have 10+hours to finish thi.docxPlease carefully check the due timeyou have 10+hours to finish thi.docx
Please carefully check the due timeyou have 10+hours to finish thi.docx
ajoy213 views
please check the folloing due today and in 935 Call a local met.docx von ajoy21
please check the folloing due today and in 935 Call a local met.docxplease check the folloing due today and in 935 Call a local met.docx
please check the folloing due today and in 935 Call a local met.docx
ajoy213 views
Please check the attachment for my paper.Please add citations to a.docx von ajoy21
Please check the attachment for my paper.Please add citations to a.docxPlease check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docx
ajoy212 views
Please carefully review the information in Chapter 2 relative to wha.docx von ajoy21
Please carefully review the information in Chapter 2 relative to wha.docxPlease carefully review the information in Chapter 2 relative to wha.docx
Please carefully review the information in Chapter 2 relative to wha.docx
ajoy214 views
Please choose one of the following questions and write a paper of up.docx von ajoy21
Please choose one of the following questions and write a paper of up.docxPlease choose one of the following questions and write a paper of up.docx
Please choose one of the following questions and write a paper of up.docx
ajoy214 views
Please build a cultural metaphor for a country besides the United St.docx von ajoy21
Please build a cultural metaphor for a country besides the United St.docxPlease build a cultural metaphor for a country besides the United St.docx
Please build a cultural metaphor for a country besides the United St.docx
ajoy214 views
Please be sure you can deliver a quality response, mantain  honework.docx von ajoy21
Please be sure you can deliver a quality response, mantain  honework.docxPlease be sure you can deliver a quality response, mantain  honework.docx
Please be sure you can deliver a quality response, mantain  honework.docx
ajoy213 views

Último

JQUERY.pdf von
JQUERY.pdfJQUERY.pdf
JQUERY.pdfArthyR3
107 views22 Folien
DISTILLATION.pptx von
DISTILLATION.pptxDISTILLATION.pptx
DISTILLATION.pptxAnupkumar Sharma
75 views47 Folien
Papal.pdf von
Papal.pdfPapal.pdf
Papal.pdfMariaKenney3
73 views24 Folien
What is Digital Transformation? von
What is Digital Transformation?What is Digital Transformation?
What is Digital Transformation?Mark Brown
41 views11 Folien
Monthly Information Session for MV Asterix (November) von
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)Esquimalt MFRC
213 views26 Folien
11.30.23A Poverty and Inequality in America.pptx von
11.30.23A Poverty and Inequality in America.pptx11.30.23A Poverty and Inequality in America.pptx
11.30.23A Poverty and Inequality in America.pptxmary850239
181 views18 Folien

Último(20)

JQUERY.pdf von ArthyR3
JQUERY.pdfJQUERY.pdf
JQUERY.pdf
ArthyR3107 views
What is Digital Transformation? von Mark Brown
What is Digital Transformation?What is Digital Transformation?
What is Digital Transformation?
Mark Brown41 views
Monthly Information Session for MV Asterix (November) von Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC213 views
11.30.23A Poverty and Inequality in America.pptx von mary850239
11.30.23A Poverty and Inequality in America.pptx11.30.23A Poverty and Inequality in America.pptx
11.30.23A Poverty and Inequality in America.pptx
mary850239181 views
UNIT NO 13 ORGANISMS AND POPULATION.pptx von Madhuri Bhande
UNIT NO 13 ORGANISMS AND POPULATION.pptxUNIT NO 13 ORGANISMS AND POPULATION.pptx
UNIT NO 13 ORGANISMS AND POPULATION.pptx
Madhuri Bhande43 views
Education of marginalized and socially disadvantages segments.pptx von GarimaBhati5
Education of marginalized and socially disadvantages segments.pptxEducation of marginalized and socially disadvantages segments.pptx
Education of marginalized and socially disadvantages segments.pptx
GarimaBhati547 views
Career Building in AI - Technologies, Trends and Opportunities von WebStackAcademy
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
WebStackAcademy47 views
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx von Niranjan Chavan
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptxGuidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx
Niranjan Chavan42 views
JRN 362 - Lecture Twenty-Two von Rich Hanley
JRN 362 - Lecture Twenty-TwoJRN 362 - Lecture Twenty-Two
JRN 362 - Lecture Twenty-Two
Rich Hanley39 views
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice von Taste
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a ChoiceCreative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Taste52 views
Pharmaceutical Analysis PPT (BP 102T) von yakshpharmacy009
Pharmaceutical Analysis PPT (BP 102T) Pharmaceutical Analysis PPT (BP 102T)
Pharmaceutical Analysis PPT (BP 102T)
yakshpharmacy009116 views

Write an abstract Student class that stores a students name and all.docx

  • 1. Write an abstract Student class that stores a student's name and all of their grades for a course. There is no limit on the number of graded assignments a course may have. Grades for a course may be characters, integers, doubles, or strings (i.e. a professor may decide to give grades in terms of A, B, C, etc., as 90, 93, 81, etc., as 81.4, 82.1, 95.4, etc., or as "acceptable", "excellent", "poor", etc.) Whatever data type is used for the grades in a course will be the same for all assignments in that course. In other words, if one grade in a course is a character, they will all be characters - it's not possible for one assignment to be given a letter grade and another an integer grade. The class should provide methods to add a grade, and to retrieve a specific grade (for example, retrieving the student's score on the third assignment). Remember that this is an abstract class - you need to provide the class's data fields and the method signatures, but not the implementations for the methods. Write a program that adds one million numbers to the beginning of an ArrayList and a Linked List. Time how long this takes in seconds. Which one is faster? Why? (Provide a detailed explanation of why the faster one is faster as a comment in your code.) Write a program that adds one million numbers to an ArrayList and a LinkedList and then remove these numbers one at a time from the end of the list. Time how long this takes in seconds. Which one is faster? Why? (Provide a detailed explanation of why the faster one is faster as a comment in your code.) Solution Problem 2:
  • 2. import java.util.ArrayList; public abstract class Student<T>{ String name; ArrayList<T> grades; public Student() { grades = new ArrayList<T>(); } abstract void addGrade(T grade); abstract T addGrade(int assignment); } Problem 3: import java.util.ArrayList; import java.util.LinkedList; public abstract class Student<T>{ public static void main(String args[]) { ArrayList<Integer> al = new ArrayList<Integer>(); LinkedList<Integer> ll = new LinkedList<Integer>(); long startTime, stopTime, elapsedTime; startTime = System.currentTimeMillis(); for(int i = 1; i <= 1000000; i++){ al.add(0, i); } stopTime = System.currentTimeMillis();
  • 3. elapsedTime = stopTime - startTime; System.out.println("In case of ArrayList, time: " + elapsedTime); startTime = System.currentTimeMillis(); for(int i = 1; i <= 1000000; i++){ ll.add(0, i); } stopTime = System.currentTimeMillis(); elapsedTime = stopTime - startTime; System.out.println("In case of LinkedList, time: " + elapsedTime); // LinkedList is faster in adding 1 million elements at the beginning, because in ArrayList, while adding any element in the beginning, all the subsequent elements have to be moved 1 place forward } } Problem 4: import java.util.ArrayList; import java.util.LinkedList; public abstract class Student<T>{
  • 4. public static void main(String args[]) { ArrayList<Integer> al = new ArrayList<Integer>(); LinkedList<Integer> ll = new LinkedList<Integer>(); long startTime, stopTime, elapsedTime; startTime = System.currentTimeMillis(); for(int i = 1; i <= 1000000; i++){ al.add(i); } stopTime = System.currentTimeMillis(); elapsedTime = stopTime - startTime; System.out.println("In case of ArrayList, time: " + elapsedTime); startTime = System.currentTimeMillis(); for(int i = 1; i <= 1000000; i++){ ll.add(i); } stopTime = System.currentTimeMillis(); elapsedTime = stopTime - startTime; System.out.println("In case of LinkedList, time: " + elapsedTime); // ArrayList is faster in adding 1 million elements at the end, because in LinkedList, while adding any element in the
  • 5. end, we have to traverse all the way to the end of the list } }