SlideShare a Scribd company logo
1 of 3
Download to read offline
Develop a program to maintain a list of homework assignments. When an assignment is
assigned, add it to the list, and when it is completed, remove it. You should keep track of the due
date. Your program should provide the following services: 1. Add a new assignment. 2. Remove
an assignment. 3. Provide a list of the assignments in the order they were assigned. 4. Find the
assignment(s) with the earliest due date.
Solution
import java.util.ListIterator;
import java.util.LinkedList;
import java.util.Scanner.*;
public class HomeworkList
{
private LinkedList theList;
public HomeworkList()
{
theList = new LinkedList();
}
public void add(Assignment assignment)
{
theList.addLast(assignment);
}
public void remove(Assignment assignment)
{
theList.remove(assignment);
}
public void showAssignments()
{
String message;
int i = 1;
for (Assignment assignment : theList)
{
message = "Assignment #" + (i++) +": " +assignment.getDescription() + " Due date: "
+assignment.getDueDate();
System.out.println(message);
}
}
public Assignment findEarliest()
{
Assignment earliest = null;
Assignment current;
ListIterator iter = theList.listIterator();
if (iter.hasNext())
{
earliest = iter.next();
while (iter.hasNext())
{
current = iter.next();
if (current.compareTo(earliest) < 0)
{
earliest = current;
}
}
}
return earliest;
}
Public static void main(String args[]){
HomeWorkList hwl = new HomeWorkList();
Scanner sr = new Scanner(System.in);
System.out.println("Enetr your choice:");
int choice=sr.nextInt();
System.out.println("Please choose your choice");
System.out.println("1.add asignment" 
" 2. Remove assignment" 
"3.List of assignments"
"4.Find the arelist asignment" 
"5. Exit");
switch (choice)
{
case 1:
hwl.add();
break;
case 2:
hwl.remove();
break;
case 3:
hwl.showAssignmnets();
break;
case 4:
hwl.findEarliest();
break;
default:
System.out.println("Invalid choice");
}
}
}

More Related Content

Similar to Develop a program to maintain a list of homework assignments. When a.pdf

Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
Eelco Visser
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdf
aromalcom
 
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
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
Khurshid Asghar
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
trixiacruz
 
collectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptxcollectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptx
hemanth248901
 
Introduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdfIntroduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdf
arpitaeron555
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
asarudheen07
 

Similar to Develop a program to maintain a list of homework assignments. When a.pdf (20)

Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
Java 103
Java 103Java 103
Java 103
 
Uta005
Uta005Uta005
Uta005
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdf
 
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
 
Write a program that creates a LinkedList object of 10 characters- the.docx
Write a program that creates a LinkedList object of 10 characters- the.docxWrite a program that creates a LinkedList object of 10 characters- the.docx
Write a program that creates a LinkedList object of 10 characters- the.docx
 
ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com
 
Linq Introduction
Linq IntroductionLinq Introduction
Linq Introduction
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
 
(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
 
collectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptxcollectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptx
 
Introduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdfIntroduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdf
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
 
54240326 (1)
54240326 (1)54240326 (1)
54240326 (1)
 
54240326 copy
54240326   copy54240326   copy
54240326 copy
 
Function
FunctionFunction
Function
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 

More from fathimalinks

Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdfWrite the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
fathimalinks
 
Why are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdfWhy are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdf
fathimalinks
 
This is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdfThis is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdf
fathimalinks
 
There is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdfThere is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdf
fathimalinks
 
Research and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdfResearch and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdf
fathimalinks
 
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdfQ1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
fathimalinks
 
Please revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdfPlease revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdf
fathimalinks
 
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdfNegligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
fathimalinks
 

More from fathimalinks (20)

Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdfWrite the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
 
Write a program in C++ that declares a structure to store the code n.pdf
Write a program in C++ that declares a structure to store the code n.pdfWrite a program in C++ that declares a structure to store the code n.pdf
Write a program in C++ that declares a structure to store the code n.pdf
 
Write a generic VBA Sub procedure to compute the value of the follow.pdf
Write a generic VBA Sub procedure to compute the value of the follow.pdfWrite a generic VBA Sub procedure to compute the value of the follow.pdf
Write a generic VBA Sub procedure to compute the value of the follow.pdf
 
Why are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdfWhy are standards needed in data communication and networking What .pdf
Why are standards needed in data communication and networking What .pdf
 
Which of the following are mismatched A. Giordia - transmitted by f.pdf
Which of the following are mismatched  A. Giordia - transmitted by f.pdfWhich of the following are mismatched  A. Giordia - transmitted by f.pdf
Which of the following are mismatched A. Giordia - transmitted by f.pdf
 
Which of the following statements about human evolution is correct.pdf
Which of the following statements about human evolution is correct.pdfWhich of the following statements about human evolution is correct.pdf
Which of the following statements about human evolution is correct.pdf
 
What are the six major pollutions in the National Ambient Air Qualit.pdf
What are the six major pollutions in the National Ambient Air Qualit.pdfWhat are the six major pollutions in the National Ambient Air Qualit.pdf
What are the six major pollutions in the National Ambient Air Qualit.pdf
 
UPS Worldpart DiscussionWhat do you think are the operational str.pdf
UPS Worldpart DiscussionWhat do you think are the operational str.pdfUPS Worldpart DiscussionWhat do you think are the operational str.pdf
UPS Worldpart DiscussionWhat do you think are the operational str.pdf
 
True or False Justify your answer.Using multilevel signaling, it .pdf
True or False Justify your answer.Using multilevel signaling, it .pdfTrue or False Justify your answer.Using multilevel signaling, it .pdf
True or False Justify your answer.Using multilevel signaling, it .pdf
 
This is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdfThis is question about excel cuers wish to answer shortly how to use.pdf
This is question about excel cuers wish to answer shortly how to use.pdf
 
There is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdfThere is a requirement to design a system to sense the presence of gl.pdf
There is a requirement to design a system to sense the presence of gl.pdf
 
The investments of Charger Inc. include a single investment 11,010 .pdf
The investments of Charger Inc. include a single investment 11,010 .pdfThe investments of Charger Inc. include a single investment 11,010 .pdf
The investments of Charger Inc. include a single investment 11,010 .pdf
 
RNA polymerasebinds to DNA after the double strands have been unwoun.pdf
RNA polymerasebinds to DNA after the double strands have been unwoun.pdfRNA polymerasebinds to DNA after the double strands have been unwoun.pdf
RNA polymerasebinds to DNA after the double strands have been unwoun.pdf
 
Research and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdfResearch and explain the deviant actions of the Los Angeles Police D.pdf
Research and explain the deviant actions of the Los Angeles Police D.pdf
 
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdfQuestion 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
Question 1 10 points Save A TALIA Contribute NINA Co Contribute TALIA.pdf
 
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdfQ1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
Q1. Print all the odd numbers from 1 to a user specifiable upper lim.pdf
 
Please revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdfPlease revise the answer bellow.Q1. What historically have been Ap.pdf
Please revise the answer bellow.Q1. What historically have been Ap.pdf
 
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdfNegligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
Negligence Curtis R. Wilhelm owned beehives and kept the hives on pr.pdf
 
List and explain at least three popular sixteenth century dance type.pdf
List and explain at least three popular sixteenth century dance type.pdfList and explain at least three popular sixteenth century dance type.pdf
List and explain at least three popular sixteenth century dance type.pdf
 
Introduction to Database Management SystemConsider the following .pdf
Introduction to Database Management SystemConsider the following .pdfIntroduction to Database Management SystemConsider the following .pdf
Introduction to Database Management SystemConsider the following .pdf
 

Recently uploaded

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
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
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 

Develop a program to maintain a list of homework assignments. When a.pdf

  • 1. Develop a program to maintain a list of homework assignments. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should provide the following services: 1. Add a new assignment. 2. Remove an assignment. 3. Provide a list of the assignments in the order they were assigned. 4. Find the assignment(s) with the earliest due date. Solution import java.util.ListIterator; import java.util.LinkedList; import java.util.Scanner.*; public class HomeworkList { private LinkedList theList; public HomeworkList() { theList = new LinkedList(); } public void add(Assignment assignment) { theList.addLast(assignment); } public void remove(Assignment assignment) { theList.remove(assignment); } public void showAssignments() { String message; int i = 1; for (Assignment assignment : theList) { message = "Assignment #" + (i++) +": " +assignment.getDescription() + " Due date: " +assignment.getDueDate();
  • 2. System.out.println(message); } } public Assignment findEarliest() { Assignment earliest = null; Assignment current; ListIterator iter = theList.listIterator(); if (iter.hasNext()) { earliest = iter.next(); while (iter.hasNext()) { current = iter.next(); if (current.compareTo(earliest) < 0) { earliest = current; } } } return earliest; } Public static void main(String args[]){ HomeWorkList hwl = new HomeWorkList(); Scanner sr = new Scanner(System.in); System.out.println("Enetr your choice:"); int choice=sr.nextInt(); System.out.println("Please choose your choice"); System.out.println("1.add asignment" " 2. Remove assignment" "3.List of assignments" "4.Find the arelist asignment" "5. Exit"); switch (choice)
  • 3. { case 1: hwl.add(); break; case 2: hwl.remove(); break; case 3: hwl.showAssignmnets(); break; case 4: hwl.findEarliest(); break; default: System.out.println("Invalid choice"); } } }