SlideShare a Scribd company logo
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 (20)

PDF
The Ring programming language version 1.5.2 book - Part 21 of 181
Mahmoud Samir Fayed
 
PDF
Lab Manual-OOP.pdf
MUNAZARAZZAQELEA
 
DOCX
Create a JAVA Program that traverses through an array recursively- rat.docx
mrichard5
 
PPTX
Basic java, java collection Framework and Date Time API
jagriti srivastava
 
PPTX
Java 103
Manuela Grindei
 
DOCX
Uta005
Daman Toor
 
PDF
Lecture 5: Functional Programming
Eelco Visser
 
PDF
In java , I want you to implement a Data Structure known as a Doubly.pdf
aromalcom
 
PPT
M251_Meeting 7 (Exception Handling and Text IO).ppt
smartashammari
 
PDF
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
freddysarabia1
 
PPTX
Collection implementation classes - Arraylist, linkedlist, Stack
RajalakshmiS74
 
DOCX
Write a program that creates a LinkedList object of 10 characters- the.docx
lez31palka
 
DOCX
ECET 370 Exceptional Education - snaptutorial.com
donaldzs157
 
PPTX
Linq Introduction
Neeraj Kaushik
 
DOC
Object oriented programming la bmanual jntu
Khurshid Asghar
 
DOCX
(674335607) cs2309 java-lab-manual
Chandrapriya Jayabal
 
PPT
3 functions and class
trixiacruz
 
PPTX
collectionframework-141116005344-conversion-gate01.pptx
hemanth248901
 
PDF
Introduction and BackgroundIn recent lectures we discussed usi.pdf
arpitaeron555
 
PPTX
M251_Meeting_ jAVAAAAAAAAAAAAAAAAAA.pptx
smartashammari
 
The Ring programming language version 1.5.2 book - Part 21 of 181
Mahmoud Samir Fayed
 
Lab Manual-OOP.pdf
MUNAZARAZZAQELEA
 
Create a JAVA Program that traverses through an array recursively- rat.docx
mrichard5
 
Basic java, java collection Framework and Date Time API
jagriti srivastava
 
Java 103
Manuela Grindei
 
Uta005
Daman Toor
 
Lecture 5: Functional Programming
Eelco Visser
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
aromalcom
 
M251_Meeting 7 (Exception Handling and Text IO).ppt
smartashammari
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
freddysarabia1
 
Collection implementation classes - Arraylist, linkedlist, Stack
RajalakshmiS74
 
Write a program that creates a LinkedList object of 10 characters- the.docx
lez31palka
 
ECET 370 Exceptional Education - snaptutorial.com
donaldzs157
 
Linq Introduction
Neeraj Kaushik
 
Object oriented programming la bmanual jntu
Khurshid Asghar
 
(674335607) cs2309 java-lab-manual
Chandrapriya Jayabal
 
3 functions and class
trixiacruz
 
collectionframework-141116005344-conversion-gate01.pptx
hemanth248901
 
Introduction and BackgroundIn recent lectures we discussed usi.pdf
arpitaeron555
 
M251_Meeting_ jAVAAAAAAAAAAAAAAAAAA.pptx
smartashammari
 

More from fathimalinks (20)

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

Recently uploaded (20)

PDF
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PPTX
Presentation: Climate Citizenship Digital Education
Karl Donert
 
PPTX
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
PPT on the Development of Education in the Victorian England
Beena E S
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
Presentation: Climate Citizenship Digital Education
Karl Donert
 
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Ad

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"); } } }