SlideShare a Scribd company logo
import java.util.ArrayList;
public class Checkout{
private ArrayList checkoutList;
Checkout(){
checkoutList= new ArrayList();
}
public int numberOfItems(){
return checkoutList.size();
}
public int totalCost(){
int sum=0;
for (Item i : checkoutList){
sum+=i.getCost();
}
return sum;
}
public int totalTax(){
return (int) java.lang.Math.
round
(GroceryStore.
TAX_RATE
*totalCost()/100.0);
}
public void clear(){
checkoutList.clear();
}
public void enterItem(Item i){
checkoutList.add(i);
}
public String toString(){
;
System.
out
.println("t"+GroceryStore.
STORE_NAME
);
System.
out
.println("nt-------------------");
for (Item i : checkoutList){
System.
out
.println(i.toString());
}
System.
out
.println("nTax "+GroceryStore.
cents2dollarsAndCents
(totalTax()));
System.
out
.println("nTotal Cost "+GroceryStore.
cents2dollarsAndCents
(totalCost()+totalTax()));
return "";
}
}
// Test Check out
public class TestCheckout {
public static void main(String[] args) {
Checkout checkout = new Checkout();
checkout.enterItem(new Rice("Basmati Rice", 2.25, 399));
checkout.enterItem(new Baguette("Wheat Baguette", 105));
checkout.enterItem(new FlavoredBaguette("White Baguette",
145, "Chocolate", 50));
checkout.enterItem(new Egg("Grade A Organic Eggs", 4,
399));
System.
out
.println("nNumber of items: " + checkout.numberOfItems() +
"n");
System.
out
.println("nTotal cost: " + checkout.totalCost() + "n");
System.
out
.println("nTotal tax: " + checkout.totalTax() + "n");
System.
out
.println("nCost + Tax: " + (checkout.totalCost() +
checkout.totalTax()) + "n");
System.
out
.println(checkout);
checkout.clear();
checkout.enterItem(new Baguette("Organic Baguette", 145));
checkout.enterItem(new FlavoredBaguette("Wheat Baguette",
105, "Caramel", 50));
checkout.enterItem(new Rice("Indian Brown Rice", 1.33, 89));
checkout.enterItem(new Egg("Grade B Egg", 4, 399));
checkout.enterItem(new Rice("Arabic White Rice", 1.5, 209));
checkout.enterItem(new Rice("Spanish Yellow Rice", 3.0,
109));
System.
out
.println("nNumber of items: " + checkout.numberOfItems() +
"n");
System.
out
.println("nTotal cost: " + checkout.totalCost() + "n");
System.
out
.println("nTotal tax: " + checkout.totalTax() + "n");
System.
out
.println("nCost + Tax: " + (checkout.totalCost() +
checkout.totalTax()) + "n");
System.
out
.println(checkout);
}
//Baguette
public class Baguette extends Item {
private double cost;
public Baguette(String name, double cost) {
super(name);
this.cost = cost;
}
@Override
public int getCost()
{
return (int)Math.
ceil
(cost);
}
@Override
public String toString() {
return name+" @" + GroceryStore.
cents2dollarsAndCents
(getCost());
}
}
public class Rice extends Item {
double weight;
double price;
public Rice(String name, double weight, double price) {
super(name);
this.weight = weight;
this.price = price;
}
@Override
public int getCost() {
return (int) Math.
ceil
(weight * price);
}
@Override
public String toString() {
return "rice" + weight + "lbs @" + GroceryStore.
cents2dollarsAndCents
(getCost());
}
}

More Related Content

Similar to import java.util.ArrayList;public class Checkout{private.docx

public static ArrayListInteger doArrayListInsertAtMedian(int nu.pdf
public static ArrayListInteger doArrayListInsertAtMedian(int nu.pdfpublic static ArrayListInteger doArrayListInsertAtMedian(int nu.pdf
public static ArrayListInteger doArrayListInsertAtMedian(int nu.pdf
arihanthtoysandgifts
 
20070329 Java Programing Tips
20070329 Java Programing Tips20070329 Java Programing Tips
20070329 Java Programing Tips
Shingo Furuyama
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdf
SIGMATAX1
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
fathimafancyjeweller
 
Beautiful java script
Beautiful java scriptBeautiful java script
Beautiful java script
Ürgo Ringo
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
Unity Technologies Japan K.K.
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
Jafar Nesargi
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
info30292
 
You are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdfYou are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdf
JUSTSTYLISH3B2MOHALI
 
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdfHello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
flashfashioncasualwe
 
Please add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docxPlease add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docx
Stewartt0kJohnstonh
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
Darwin Durand
 
Here is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdfHere is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdf
anand1213
 
Code javascript
Code javascriptCode javascript
Code javascript
Ray Ray
 
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
 ReverseList.javaimport java.util.ArrayList;public class Rever.pdf ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
aryan9007
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
akkhan101
 
Easy Button
Easy ButtonEasy Button
Easy Button
Adam Dale
 

Similar to import java.util.ArrayList;public class Checkout{private.docx (17)

public static ArrayListInteger doArrayListInsertAtMedian(int nu.pdf
public static ArrayListInteger doArrayListInsertAtMedian(int nu.pdfpublic static ArrayListInteger doArrayListInsertAtMedian(int nu.pdf
public static ArrayListInteger doArrayListInsertAtMedian(int nu.pdf
 
20070329 Java Programing Tips
20070329 Java Programing Tips20070329 Java Programing Tips
20070329 Java Programing Tips
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdf
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
 
Beautiful java script
Beautiful java scriptBeautiful java script
Beautiful java script
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
 
You are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdfYou are to simulate a dispatcher using a priority queue system in C+.pdf
You are to simulate a dispatcher using a priority queue system in C+.pdf
 
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdfHello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
 
Please add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docxPlease add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docx
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Here is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdfHere is the codeimport java.util.; class GroceryItem { Stri.pdf
Here is the codeimport java.util.; class GroceryItem { Stri.pdf
 
Code javascript
Code javascriptCode javascript
Code javascript
 
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
 ReverseList.javaimport java.util.ArrayList;public class Rever.pdf ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
Easy Button
Easy ButtonEasy Button
Easy Button
 

More from Abhinav816839

Clinical Reasoning Case Study Total Parenteral NutritionName ____.docx
Clinical Reasoning Case Study Total Parenteral NutritionName ____.docxClinical Reasoning Case Study Total Parenteral NutritionName ____.docx
Clinical Reasoning Case Study Total Parenteral NutritionName ____.docx
Abhinav816839
 
Correctional Health Care AssignmentCourse Objective for Assignme.docx
Correctional Health Care AssignmentCourse Objective for Assignme.docxCorrectional Health Care AssignmentCourse Objective for Assignme.docx
Correctional Health Care AssignmentCourse Objective for Assignme.docx
Abhinav816839
 
Class Response 1 Making or implementing policies should ultima.docx
Class Response 1 Making or implementing policies should ultima.docxClass Response 1 Making or implementing policies should ultima.docx
Class Response 1 Making or implementing policies should ultima.docx
Abhinav816839
 
Chapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docx
Chapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docxChapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docx
Chapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docx
Abhinav816839
 
Chapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docx
Chapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docxChapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docx
Chapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docx
Abhinav816839
 
CS547 Wireless Networking and Security Exam 1 Questio.docx
CS547 Wireless Networking and Security Exam 1  Questio.docxCS547 Wireless Networking and Security Exam 1  Questio.docx
CS547 Wireless Networking and Security Exam 1 Questio.docx
Abhinav816839
 
Communicating professionally and ethically is an essential ski.docx
Communicating professionally and ethically is an essential ski.docxCommunicating professionally and ethically is an essential ski.docx
Communicating professionally and ethically is an essential ski.docx
Abhinav816839
 
Case Study The HouseCallCompany.com Abstract The case.docx
Case Study The HouseCallCompany.com  Abstract The case.docxCase Study The HouseCallCompany.com  Abstract The case.docx
Case Study The HouseCallCompany.com Abstract The case.docx
Abhinav816839
 
CHAPTER 5Risk Response and MitigationIn this chapter, you will.docx
CHAPTER 5Risk Response and MitigationIn this chapter, you will.docxCHAPTER 5Risk Response and MitigationIn this chapter, you will.docx
CHAPTER 5Risk Response and MitigationIn this chapter, you will.docx
Abhinav816839
 
BiopsychologySensation and PerceptionInstructionsTake a mom.docx
BiopsychologySensation and PerceptionInstructionsTake a mom.docxBiopsychologySensation and PerceptionInstructionsTake a mom.docx
BiopsychologySensation and PerceptionInstructionsTake a mom.docx
Abhinav816839
 
Chapter 2Historical Perspectives on Case ManagementChapter In.docx
Chapter 2Historical Perspectives on Case ManagementChapter In.docxChapter 2Historical Perspectives on Case ManagementChapter In.docx
Chapter 2Historical Perspectives on Case ManagementChapter In.docx
Abhinav816839
 
Compare and Contrast Systems Development Life Cycle (SDLC Mo.docx
Compare and Contrast Systems Development Life Cycle (SDLC Mo.docxCompare and Contrast Systems Development Life Cycle (SDLC Mo.docx
Compare and Contrast Systems Development Life Cycle (SDLC Mo.docx
Abhinav816839
 
C H A P T E R F O U R PROBLEMS OF COMMUNICATIONCri.docx
C H A P T E R  F O U R  PROBLEMS OF COMMUNICATIONCri.docxC H A P T E R  F O U R  PROBLEMS OF COMMUNICATIONCri.docx
C H A P T E R F O U R PROBLEMS OF COMMUNICATIONCri.docx
Abhinav816839
 
By Day 6 of Week Due 917Respond to at least two of your c.docx
By Day 6 of Week Due 917Respond to at least two of your c.docxBy Day 6 of Week Due 917Respond to at least two of your c.docx
By Day 6 of Week Due 917Respond to at least two of your c.docx
Abhinav816839
 
ASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name .docx
ASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name                .docxASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name                .docx
ASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name .docx
Abhinav816839
 
3 pages excluding the title and reference page.Describe how Ph.docx
3 pages excluding the title and reference page.Describe how Ph.docx3 pages excluding the title and reference page.Describe how Ph.docx
3 pages excluding the title and reference page.Describe how Ph.docx
Abhinav816839
 
91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx
91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx
91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx
Abhinav816839
 
All details are posted in the documentPlease use this topics for.docx
All details are posted in the documentPlease use this topics for.docxAll details are posted in the documentPlease use this topics for.docx
All details are posted in the documentPlease use this topics for.docx
Abhinav816839
 
1, Describe the mind as a stream of consciousness, and what it revea.docx
1, Describe the mind as a stream of consciousness, and what it revea.docx1, Describe the mind as a stream of consciousness, and what it revea.docx
1, Describe the mind as a stream of consciousness, and what it revea.docx
Abhinav816839
 
2Some of the ways that students are diverse in todays schools .docx
2Some of the ways that students are diverse in todays schools .docx2Some of the ways that students are diverse in todays schools .docx
2Some of the ways that students are diverse in todays schools .docx
Abhinav816839
 

More from Abhinav816839 (20)

Clinical Reasoning Case Study Total Parenteral NutritionName ____.docx
Clinical Reasoning Case Study Total Parenteral NutritionName ____.docxClinical Reasoning Case Study Total Parenteral NutritionName ____.docx
Clinical Reasoning Case Study Total Parenteral NutritionName ____.docx
 
Correctional Health Care AssignmentCourse Objective for Assignme.docx
Correctional Health Care AssignmentCourse Objective for Assignme.docxCorrectional Health Care AssignmentCourse Objective for Assignme.docx
Correctional Health Care AssignmentCourse Objective for Assignme.docx
 
Class Response 1 Making or implementing policies should ultima.docx
Class Response 1 Making or implementing policies should ultima.docxClass Response 1 Making or implementing policies should ultima.docx
Class Response 1 Making or implementing policies should ultima.docx
 
Chapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docx
Chapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docxChapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docx
Chapter 3 - Evaluation Rubric Criteria Does Not Meet 0.01 .docx
 
Chapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docx
Chapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docxChapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docx
Chapter 4 (Sexual Assault)Points Possible 20Deliverable Len.docx
 
CS547 Wireless Networking and Security Exam 1 Questio.docx
CS547 Wireless Networking and Security Exam 1  Questio.docxCS547 Wireless Networking and Security Exam 1  Questio.docx
CS547 Wireless Networking and Security Exam 1 Questio.docx
 
Communicating professionally and ethically is an essential ski.docx
Communicating professionally and ethically is an essential ski.docxCommunicating professionally and ethically is an essential ski.docx
Communicating professionally and ethically is an essential ski.docx
 
Case Study The HouseCallCompany.com Abstract The case.docx
Case Study The HouseCallCompany.com  Abstract The case.docxCase Study The HouseCallCompany.com  Abstract The case.docx
Case Study The HouseCallCompany.com Abstract The case.docx
 
CHAPTER 5Risk Response and MitigationIn this chapter, you will.docx
CHAPTER 5Risk Response and MitigationIn this chapter, you will.docxCHAPTER 5Risk Response and MitigationIn this chapter, you will.docx
CHAPTER 5Risk Response and MitigationIn this chapter, you will.docx
 
BiopsychologySensation and PerceptionInstructionsTake a mom.docx
BiopsychologySensation and PerceptionInstructionsTake a mom.docxBiopsychologySensation and PerceptionInstructionsTake a mom.docx
BiopsychologySensation and PerceptionInstructionsTake a mom.docx
 
Chapter 2Historical Perspectives on Case ManagementChapter In.docx
Chapter 2Historical Perspectives on Case ManagementChapter In.docxChapter 2Historical Perspectives on Case ManagementChapter In.docx
Chapter 2Historical Perspectives on Case ManagementChapter In.docx
 
Compare and Contrast Systems Development Life Cycle (SDLC Mo.docx
Compare and Contrast Systems Development Life Cycle (SDLC Mo.docxCompare and Contrast Systems Development Life Cycle (SDLC Mo.docx
Compare and Contrast Systems Development Life Cycle (SDLC Mo.docx
 
C H A P T E R F O U R PROBLEMS OF COMMUNICATIONCri.docx
C H A P T E R  F O U R  PROBLEMS OF COMMUNICATIONCri.docxC H A P T E R  F O U R  PROBLEMS OF COMMUNICATIONCri.docx
C H A P T E R F O U R PROBLEMS OF COMMUNICATIONCri.docx
 
By Day 6 of Week Due 917Respond to at least two of your c.docx
By Day 6 of Week Due 917Respond to at least two of your c.docxBy Day 6 of Week Due 917Respond to at least two of your c.docx
By Day 6 of Week Due 917Respond to at least two of your c.docx
 
ASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name .docx
ASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name                .docxASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name                .docx
ASSIGNMENT 3 (CHAPTERS 8-9) QUESTIONS Name .docx
 
3 pages excluding the title and reference page.Describe how Ph.docx
3 pages excluding the title and reference page.Describe how Ph.docx3 pages excluding the title and reference page.Describe how Ph.docx
3 pages excluding the title and reference page.Describe how Ph.docx
 
91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx
91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx
91422, 1134 AM Printhttpscontent.uagc.eduprintMcNe.docx
 
All details are posted in the documentPlease use this topics for.docx
All details are posted in the documentPlease use this topics for.docxAll details are posted in the documentPlease use this topics for.docx
All details are posted in the documentPlease use this topics for.docx
 
1, Describe the mind as a stream of consciousness, and what it revea.docx
1, Describe the mind as a stream of consciousness, and what it revea.docx1, Describe the mind as a stream of consciousness, and what it revea.docx
1, Describe the mind as a stream of consciousness, and what it revea.docx
 
2Some of the ways that students are diverse in todays schools .docx
2Some of the ways that students are diverse in todays schools .docx2Some of the ways that students are diverse in todays schools .docx
2Some of the ways that students are diverse in todays schools .docx
 

Recently uploaded

RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 

import java.util.ArrayList;public class Checkout{private.docx

  • 1. import java.util.ArrayList; public class Checkout{ private ArrayList checkoutList; Checkout(){ checkoutList= new ArrayList(); } public int numberOfItems(){ return checkoutList.size(); } public int totalCost(){ int sum=0; for (Item i : checkoutList){ sum+=i.getCost(); } return sum; } public int totalTax(){
  • 2. return (int) java.lang.Math. round (GroceryStore. TAX_RATE *totalCost()/100.0); } public void clear(){ checkoutList.clear(); } public void enterItem(Item i){ checkoutList.add(i); } public String toString(){ ; System. out .println("t"+GroceryStore. STORE_NAME ); System. out .println("nt-------------------"); for (Item i : checkoutList){
  • 3. System. out .println(i.toString()); } System. out .println("nTax "+GroceryStore. cents2dollarsAndCents (totalTax())); System. out .println("nTotal Cost "+GroceryStore. cents2dollarsAndCents (totalCost()+totalTax())); return ""; } } // Test Check out public class TestCheckout { public static void main(String[] args) { Checkout checkout = new Checkout(); checkout.enterItem(new Rice("Basmati Rice", 2.25, 399));
  • 4. checkout.enterItem(new Baguette("Wheat Baguette", 105)); checkout.enterItem(new FlavoredBaguette("White Baguette", 145, "Chocolate", 50)); checkout.enterItem(new Egg("Grade A Organic Eggs", 4, 399)); System. out .println("nNumber of items: " + checkout.numberOfItems() + "n"); System. out .println("nTotal cost: " + checkout.totalCost() + "n"); System. out .println("nTotal tax: " + checkout.totalTax() + "n"); System. out .println("nCost + Tax: " + (checkout.totalCost() + checkout.totalTax()) + "n"); System. out .println(checkout); checkout.clear(); checkout.enterItem(new Baguette("Organic Baguette", 145)); checkout.enterItem(new FlavoredBaguette("Wheat Baguette",
  • 5. 105, "Caramel", 50)); checkout.enterItem(new Rice("Indian Brown Rice", 1.33, 89)); checkout.enterItem(new Egg("Grade B Egg", 4, 399)); checkout.enterItem(new Rice("Arabic White Rice", 1.5, 209)); checkout.enterItem(new Rice("Spanish Yellow Rice", 3.0, 109)); System. out .println("nNumber of items: " + checkout.numberOfItems() + "n"); System. out .println("nTotal cost: " + checkout.totalCost() + "n"); System. out .println("nTotal tax: " + checkout.totalTax() + "n"); System. out .println("nCost + Tax: " + (checkout.totalCost() + checkout.totalTax()) + "n"); System. out .println(checkout); } //Baguette
  • 6. public class Baguette extends Item { private double cost; public Baguette(String name, double cost) { super(name); this.cost = cost; } @Override public int getCost() { return (int)Math. ceil (cost); } @Override public String toString() { return name+" @" + GroceryStore. cents2dollarsAndCents (getCost()); } }
  • 7. public class Rice extends Item { double weight; double price; public Rice(String name, double weight, double price) { super(name); this.weight = weight; this.price = price; } @Override public int getCost() { return (int) Math. ceil (weight * price); } @Override public String toString() { return "rice" + weight + "lbs @" + GroceryStore. cents2dollarsAndCents