Question
USE LINKEDLIST (no library) 1. Class Invoice ( the node ) that includes three instance variables: int No; // the Invoice No String CustName; //
USE LINKEDLIST (no library)
1. Class Invoice ( the node ) that includes three instance variables:
int No; // the Invoice No
String CustName; // the Customer name
int Amount; // the Invoice Amount
Invoice next; // points to the next Invoice
Default and overloaded constructors
2. Class Shop that includes two instance variables:
Invoice head;
Invoice Tail;
Your class should have the following:
A method that initializes the instance variables.
void add (int, String, int) creates and adds the Invoice information ( No, CustName and Amount) in the singly linked list.
void delete (int) to delete an Invoice in the single linked list.
void printInvoices() prints all the Invoices in the single linked list.
int countInvoices () counts the number of Invoices in the list.
int Sum () counts the summation of the Invoices amounts.
Write a test application. In the main method, do the following:
Create a Shop object.
Ask the user to enter the number of Invoices in the Shop.
Input the No, CustName and Amount of each Invoice and add it to the Shop class (Hint: Use a loop).
Print the Invoices.
Input the No. of the Invoice to be deleted. Delete the Invoice.
Print the Invoices.
Print the number of Invoice.
Print the summation of all Invoices amounts.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started