SlideShare a Scribd company logo
1 of 8
Download to read offline
Please find my solution.
Please let me know in case of any issue.
########## Invoice.java ###############
public class Invoice {
// instance variables
private String name;
private int itemNumber;
private int quantity;
private double price;
private double totalCost;
// setters
public void setName(String name) {
this.name = name;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public void setPrice(double price) {
this.price = price;
}
public void setItemNumber(int itemNumber){
this.itemNumber = itemNumber;
}
//display method
public void displayLine(){
totalCost = price*quantity;
System.out.println("Name: "+name);
System.out.println("Item Number: "+itemNumber);
System.out.println("Quantity: "+quantity);
System.out.println("Price: "+price);
System.out.println("Total Cost: "+totalCost);
}
}
################ TestInvoice.java ###################
import java.util.Scanner;
public class TestInvoice {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// creating three methods
Invoice i1 = new Invoice();
Invoice i2 = new Invoice();
Invoice i3 = new Invoice();
// input for first invoice
System.out.print("Enter name of invoice1: ");
i1.setName(sc.next());
System.out.print("Enter item number: ");
i1.setItemNumber(sc.nextInt());
System.out.print("Enter quantity: ");
i1.setQuantity(sc.nextInt());
System.out.print("Enter price: ");
i1.setPrice(sc.nextDouble());
System.out.println();
// input for second invoice
System.out.print("Enter name of invoice2: ");
i2.setName(sc.next());
System.out.print("Enter item number: ");
i2.setItemNumber(sc.nextInt());
System.out.print("Enter quantity: ");
i2.setQuantity(sc.nextInt());
System.out.print("Enter price: ");
i2.setPrice(sc.nextDouble());
System.out.println();
// input for third invoice
System.out.print("Enter name of invoice3: ");
i3.setName(sc.next());
System.out.print("Enter item number: ");
i3.setItemNumber(sc.nextInt());
System.out.print("Enter quantity: ");
i3.setQuantity(sc.nextInt());
System.out.print("Enter price: ");
i3.setPrice(sc.nextDouble());
System.out.println();
sc.close();
// displaying three invoice information
i1.displayLine();
System.out.println();
i2.displayLine();
System.out.println();
i3.displayLine();
System.out.println();
}
}
/*
Sample Output:
Enter name of invoice1: Invoice1
Enter item number: 123
Enter quantity: 21
Enter price: 34.56
Enter name of invoice2: Invoice2
Enter item number: 124
Enter quantity: 25
Enter price: 43.5
Enter name of invoice3: Invoice3
Enter item number: 125
Enter quantity: 27
Enter price: 65
Name: Invoice1
Item Number: 123
Quantity: 21
Price: 34.56
Total Cost: 725.76
Name: Invoice2
Item Number: 124
Quantity: 25
Price: 43.5
Total Cost: 1087.5
Name: Invoice3
Item Number: 125
Quantity: 27
Price: 65.0
Total Cost: 1755.0
*/
Solution
Please find my solution.
Please let me know in case of any issue.
########## Invoice.java ###############
public class Invoice {
// instance variables
private String name;
private int itemNumber;
private int quantity;
private double price;
private double totalCost;
// setters
public void setName(String name) {
this.name = name;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public void setPrice(double price) {
this.price = price;
}
public void setItemNumber(int itemNumber){
this.itemNumber = itemNumber;
}
//display method
public void displayLine(){
totalCost = price*quantity;
System.out.println("Name: "+name);
System.out.println("Item Number: "+itemNumber);
System.out.println("Quantity: "+quantity);
System.out.println("Price: "+price);
System.out.println("Total Cost: "+totalCost);
}
}
################ TestInvoice.java ###################
import java.util.Scanner;
public class TestInvoice {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// creating three methods
Invoice i1 = new Invoice();
Invoice i2 = new Invoice();
Invoice i3 = new Invoice();
// input for first invoice
System.out.print("Enter name of invoice1: ");
i1.setName(sc.next());
System.out.print("Enter item number: ");
i1.setItemNumber(sc.nextInt());
System.out.print("Enter quantity: ");
i1.setQuantity(sc.nextInt());
System.out.print("Enter price: ");
i1.setPrice(sc.nextDouble());
System.out.println();
// input for second invoice
System.out.print("Enter name of invoice2: ");
i2.setName(sc.next());
System.out.print("Enter item number: ");
i2.setItemNumber(sc.nextInt());
System.out.print("Enter quantity: ");
i2.setQuantity(sc.nextInt());
System.out.print("Enter price: ");
i2.setPrice(sc.nextDouble());
System.out.println();
// input for third invoice
System.out.print("Enter name of invoice3: ");
i3.setName(sc.next());
System.out.print("Enter item number: ");
i3.setItemNumber(sc.nextInt());
System.out.print("Enter quantity: ");
i3.setQuantity(sc.nextInt());
System.out.print("Enter price: ");
i3.setPrice(sc.nextDouble());
System.out.println();
sc.close();
// displaying three invoice information
i1.displayLine();
System.out.println();
i2.displayLine();
System.out.println();
i3.displayLine();
System.out.println();
}
}
/*
Sample Output:
Enter name of invoice1: Invoice1
Enter item number: 123
Enter quantity: 21
Enter price: 34.56
Enter name of invoice2: Invoice2
Enter item number: 124
Enter quantity: 25
Enter price: 43.5
Enter name of invoice3: Invoice3
Enter item number: 125
Enter quantity: 27
Enter price: 65
Name: Invoice1
Item Number: 123
Quantity: 21
Price: 34.56
Total Cost: 725.76
Name: Invoice2
Item Number: 124
Quantity: 25
Price: 43.5
Total Cost: 1087.5
Name: Invoice3
Item Number: 125
Quantity: 27
Price: 65.0
Total Cost: 1755.0
*/

More Related Content

Similar to Please find my solution.Please let me know in case of any issue..pdf

import java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfimport java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfaquazac
 
I received answers to 2 App requests and paid. The JAVA Apps are not.docx
I received answers to 2 App requests and paid. The JAVA Apps are not.docxI received answers to 2 App requests and paid. The JAVA Apps are not.docx
I received answers to 2 App requests and paid. The JAVA Apps are not.docxwalthamcoretta
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxwhitneyleman54422
 
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfHow do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfpnaran46
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdffantasiatheoutofthef
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfankitmobileshop235
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfcalderoncasto9163
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdffashiionbeutycare
 
131 Lab slides (all in one)
131 Lab slides (all in one)131 Lab slides (all in one)
131 Lab slides (all in one)Tak Lee
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 DevsJason Hanson
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxpriestmanmable
 
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error-   Exception in thread -main- q- Exit java-lang-.pdfHow to fix this error-   Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdfaarokyaaqua
 
Extending javascript part one
Extending javascript part oneExtending javascript part one
Extending javascript part oneVijaya Anand
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfallystraders
 

Similar to Please find my solution.Please let me know in case of any issue..pdf (18)

The Xtext Grammar Language
The Xtext Grammar LanguageThe Xtext Grammar Language
The Xtext Grammar Language
 
import java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfimport java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdf
 
I received answers to 2 App requests and paid. The JAVA Apps are not.docx
I received answers to 2 App requests and paid. The JAVA Apps are not.docxI received answers to 2 App requests and paid. The JAVA Apps are not.docx
I received answers to 2 App requests and paid. The JAVA Apps are not.docx
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
 
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfHow do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
 
131 Lab slides (all in one)
131 Lab slides (all in one)131 Lab slides (all in one)
131 Lab slides (all in one)
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 Devs
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error-   Exception in thread -main- q- Exit java-lang-.pdfHow to fix this error-   Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
 
Extending javascript part one
Extending javascript part oneExtending javascript part one
Extending javascript part one
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdf
 

More from premkhatri99

A SturmSolution A Sturm.pdf
 A SturmSolution A Sturm.pdf A SturmSolution A Sturm.pdf
A SturmSolution A Sturm.pdfpremkhatri99
 
Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdf
                     Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdf                     Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdf
Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdfpremkhatri99
 
very easy Water formula — H 2 O .pdf
                     very easy  Water formula — H 2 O                 .pdf                     very easy  Water formula — H 2 O                 .pdf
very easy Water formula — H 2 O .pdfpremkhatri99
 
TLC or Thin Layer Chromatography is performed on.pdf
                     TLC or Thin Layer Chromatography is performed on.pdf                     TLC or Thin Layer Chromatography is performed on.pdf
TLC or Thin Layer Chromatography is performed on.pdfpremkhatri99
 
The name of the compound is 2-Ethoxyethanol .pdf
                     The name of the compound is  2-Ethoxyethanol     .pdf                     The name of the compound is  2-Ethoxyethanol     .pdf
The name of the compound is 2-Ethoxyethanol .pdfpremkhatri99
 
THANKS Solution THANKS .pdf
                     THANKS Solution                     THANKS .pdf                     THANKS Solution                     THANKS .pdf
THANKS Solution THANKS .pdfpremkhatri99
 
Potassium (K) ion has an electron configuration i.pdf
                     Potassium (K) ion has an electron configuration i.pdf                     Potassium (K) ion has an electron configuration i.pdf
Potassium (K) ion has an electron configuration i.pdfpremkhatri99
 
oxidation-reduction reactions (redox reactions) a.pdf
                     oxidation-reduction reactions (redox reactions) a.pdf                     oxidation-reduction reactions (redox reactions) a.pdf
oxidation-reduction reactions (redox reactions) a.pdfpremkhatri99
 
NO reaction between these two salts, thus no equa.pdf
                     NO reaction between these two salts, thus no equa.pdf                     NO reaction between these two salts, thus no equa.pdf
NO reaction between these two salts, thus no equa.pdfpremkhatri99
 
Helium is a little lighter then a sum of two prot.pdf
                     Helium is a little lighter then a sum of two prot.pdf                     Helium is a little lighter then a sum of two prot.pdf
Helium is a little lighter then a sum of two prot.pdfpremkhatri99
 
It is F tset.The between-group degrees of freedom is 3-1=2.pdf
It is F tset.The between-group degrees of freedom is 3-1=2.pdfIt is F tset.The between-group degrees of freedom is 3-1=2.pdf
It is F tset.The between-group degrees of freedom is 3-1=2.pdfpremkhatri99
 
there is no reaction between Cu(NO3)2 and water.Solutionth.pdf
there is no reaction between Cu(NO3)2 and water.Solutionth.pdfthere is no reaction between Cu(NO3)2 and water.Solutionth.pdf
there is no reaction between Cu(NO3)2 and water.Solutionth.pdfpremkhatri99
 
There are 7 in total ( 3 up and 4 right )Differnet paths possi.pdf
There are 7 in total ( 3 up and 4 right )Differnet paths possi.pdfThere are 7 in total ( 3 up and 4 right )Differnet paths possi.pdf
There are 7 in total ( 3 up and 4 right )Differnet paths possi.pdfpremkhatri99
 
The length of a is independent of the shaft length L. Because it is .pdf
The length of a is independent of the shaft length L. Because it is .pdfThe length of a is independent of the shaft length L. Because it is .pdf
The length of a is independent of the shaft length L. Because it is .pdfpremkhatri99
 
The answer is E all of the aboveSolutionThe answer is E all of.pdf
The answer is E all of the aboveSolutionThe answer is E all of.pdfThe answer is E all of the aboveSolutionThe answer is E all of.pdf
The answer is E all of the aboveSolutionThe answer is E all of.pdfpremkhatri99
 
Suppose there is a parasite P which feeds on a species of insect.pdf
Suppose there is a parasite P which feeds on a species of insect.pdfSuppose there is a parasite P which feeds on a species of insect.pdf
Suppose there is a parasite P which feeds on a species of insect.pdfpremkhatri99
 
Run the following code to get the deisred resultfunction .pdf
Run the following code to get the deisred resultfunction .pdfRun the following code to get the deisred resultfunction .pdf
Run the following code to get the deisred resultfunction .pdfpremkhatri99
 
only the ketone at the left top changes to acid (cooH)Solution.pdf
only the ketone at the left top changes to acid (cooH)Solution.pdfonly the ketone at the left top changes to acid (cooH)Solution.pdf
only the ketone at the left top changes to acid (cooH)Solution.pdfpremkhatri99
 
P(a)=15=0.2SolutionP(a)=15=0.2.pdf
P(a)=15=0.2SolutionP(a)=15=0.2.pdfP(a)=15=0.2SolutionP(a)=15=0.2.pdf
P(a)=15=0.2SolutionP(a)=15=0.2.pdfpremkhatri99
 
net ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdf
net ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdfnet ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdf
net ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdfpremkhatri99
 

More from premkhatri99 (20)

A SturmSolution A Sturm.pdf
 A SturmSolution A Sturm.pdf A SturmSolution A Sturm.pdf
A SturmSolution A Sturm.pdf
 
Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdf
                     Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdf                     Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdf
Yes it is minus 1 (-1). Oxygen is normally -2, bu.pdf
 
very easy Water formula — H 2 O .pdf
                     very easy  Water formula — H 2 O                 .pdf                     very easy  Water formula — H 2 O                 .pdf
very easy Water formula — H 2 O .pdf
 
TLC or Thin Layer Chromatography is performed on.pdf
                     TLC or Thin Layer Chromatography is performed on.pdf                     TLC or Thin Layer Chromatography is performed on.pdf
TLC or Thin Layer Chromatography is performed on.pdf
 
The name of the compound is 2-Ethoxyethanol .pdf
                     The name of the compound is  2-Ethoxyethanol     .pdf                     The name of the compound is  2-Ethoxyethanol     .pdf
The name of the compound is 2-Ethoxyethanol .pdf
 
THANKS Solution THANKS .pdf
                     THANKS Solution                     THANKS .pdf                     THANKS Solution                     THANKS .pdf
THANKS Solution THANKS .pdf
 
Potassium (K) ion has an electron configuration i.pdf
                     Potassium (K) ion has an electron configuration i.pdf                     Potassium (K) ion has an electron configuration i.pdf
Potassium (K) ion has an electron configuration i.pdf
 
oxidation-reduction reactions (redox reactions) a.pdf
                     oxidation-reduction reactions (redox reactions) a.pdf                     oxidation-reduction reactions (redox reactions) a.pdf
oxidation-reduction reactions (redox reactions) a.pdf
 
NO reaction between these two salts, thus no equa.pdf
                     NO reaction between these two salts, thus no equa.pdf                     NO reaction between these two salts, thus no equa.pdf
NO reaction between these two salts, thus no equa.pdf
 
Helium is a little lighter then a sum of two prot.pdf
                     Helium is a little lighter then a sum of two prot.pdf                     Helium is a little lighter then a sum of two prot.pdf
Helium is a little lighter then a sum of two prot.pdf
 
It is F tset.The between-group degrees of freedom is 3-1=2.pdf
It is F tset.The between-group degrees of freedom is 3-1=2.pdfIt is F tset.The between-group degrees of freedom is 3-1=2.pdf
It is F tset.The between-group degrees of freedom is 3-1=2.pdf
 
there is no reaction between Cu(NO3)2 and water.Solutionth.pdf
there is no reaction between Cu(NO3)2 and water.Solutionth.pdfthere is no reaction between Cu(NO3)2 and water.Solutionth.pdf
there is no reaction between Cu(NO3)2 and water.Solutionth.pdf
 
There are 7 in total ( 3 up and 4 right )Differnet paths possi.pdf
There are 7 in total ( 3 up and 4 right )Differnet paths possi.pdfThere are 7 in total ( 3 up and 4 right )Differnet paths possi.pdf
There are 7 in total ( 3 up and 4 right )Differnet paths possi.pdf
 
The length of a is independent of the shaft length L. Because it is .pdf
The length of a is independent of the shaft length L. Because it is .pdfThe length of a is independent of the shaft length L. Because it is .pdf
The length of a is independent of the shaft length L. Because it is .pdf
 
The answer is E all of the aboveSolutionThe answer is E all of.pdf
The answer is E all of the aboveSolutionThe answer is E all of.pdfThe answer is E all of the aboveSolutionThe answer is E all of.pdf
The answer is E all of the aboveSolutionThe answer is E all of.pdf
 
Suppose there is a parasite P which feeds on a species of insect.pdf
Suppose there is a parasite P which feeds on a species of insect.pdfSuppose there is a parasite P which feeds on a species of insect.pdf
Suppose there is a parasite P which feeds on a species of insect.pdf
 
Run the following code to get the deisred resultfunction .pdf
Run the following code to get the deisred resultfunction .pdfRun the following code to get the deisred resultfunction .pdf
Run the following code to get the deisred resultfunction .pdf
 
only the ketone at the left top changes to acid (cooH)Solution.pdf
only the ketone at the left top changes to acid (cooH)Solution.pdfonly the ketone at the left top changes to acid (cooH)Solution.pdf
only the ketone at the left top changes to acid (cooH)Solution.pdf
 
P(a)=15=0.2SolutionP(a)=15=0.2.pdf
P(a)=15=0.2SolutionP(a)=15=0.2.pdfP(a)=15=0.2SolutionP(a)=15=0.2.pdf
P(a)=15=0.2SolutionP(a)=15=0.2.pdf
 
net ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdf
net ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdfnet ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdf
net ionic equationFe2+(aq) + S2-(aq) --- FeS(s)noteK+ and N.pdf
 

Recently uploaded

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
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 . pdfQucHHunhnh
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
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 writingTeacherCyreneCayanan
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
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.pdfJayanti Pande
 
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 ModeThiyagu K
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Recently uploaded (20)

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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
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
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
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
 
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
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Please find my solution.Please let me know in case of any issue..pdf

  • 1. Please find my solution. Please let me know in case of any issue. ########## Invoice.java ############### public class Invoice { // instance variables private String name; private int itemNumber; private int quantity; private double price; private double totalCost; // setters public void setName(String name) { this.name = name; } public void setQuantity(int quantity) { this.quantity = quantity; } public void setPrice(double price) { this.price = price; } public void setItemNumber(int itemNumber){ this.itemNumber = itemNumber; } //display method public void displayLine(){ totalCost = price*quantity; System.out.println("Name: "+name); System.out.println("Item Number: "+itemNumber); System.out.println("Quantity: "+quantity);
  • 2. System.out.println("Price: "+price); System.out.println("Total Cost: "+totalCost); } } ################ TestInvoice.java ################### import java.util.Scanner; public class TestInvoice { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // creating three methods Invoice i1 = new Invoice(); Invoice i2 = new Invoice(); Invoice i3 = new Invoice(); // input for first invoice System.out.print("Enter name of invoice1: "); i1.setName(sc.next()); System.out.print("Enter item number: "); i1.setItemNumber(sc.nextInt()); System.out.print("Enter quantity: "); i1.setQuantity(sc.nextInt()); System.out.print("Enter price: "); i1.setPrice(sc.nextDouble()); System.out.println(); // input for second invoice System.out.print("Enter name of invoice2: "); i2.setName(sc.next()); System.out.print("Enter item number: "); i2.setItemNumber(sc.nextInt()); System.out.print("Enter quantity: "); i2.setQuantity(sc.nextInt()); System.out.print("Enter price: "); i2.setPrice(sc.nextDouble());
  • 3. System.out.println(); // input for third invoice System.out.print("Enter name of invoice3: "); i3.setName(sc.next()); System.out.print("Enter item number: "); i3.setItemNumber(sc.nextInt()); System.out.print("Enter quantity: "); i3.setQuantity(sc.nextInt()); System.out.print("Enter price: "); i3.setPrice(sc.nextDouble()); System.out.println(); sc.close(); // displaying three invoice information i1.displayLine(); System.out.println(); i2.displayLine(); System.out.println(); i3.displayLine(); System.out.println(); } } /* Sample Output: Enter name of invoice1: Invoice1 Enter item number: 123 Enter quantity: 21 Enter price: 34.56 Enter name of invoice2: Invoice2 Enter item number: 124 Enter quantity: 25 Enter price: 43.5 Enter name of invoice3: Invoice3 Enter item number: 125
  • 4. Enter quantity: 27 Enter price: 65 Name: Invoice1 Item Number: 123 Quantity: 21 Price: 34.56 Total Cost: 725.76 Name: Invoice2 Item Number: 124 Quantity: 25 Price: 43.5 Total Cost: 1087.5 Name: Invoice3 Item Number: 125 Quantity: 27 Price: 65.0 Total Cost: 1755.0 */ Solution Please find my solution. Please let me know in case of any issue. ########## Invoice.java ############### public class Invoice { // instance variables private String name; private int itemNumber; private int quantity; private double price; private double totalCost; // setters public void setName(String name) { this.name = name;
  • 5. } public void setQuantity(int quantity) { this.quantity = quantity; } public void setPrice(double price) { this.price = price; } public void setItemNumber(int itemNumber){ this.itemNumber = itemNumber; } //display method public void displayLine(){ totalCost = price*quantity; System.out.println("Name: "+name); System.out.println("Item Number: "+itemNumber); System.out.println("Quantity: "+quantity); System.out.println("Price: "+price); System.out.println("Total Cost: "+totalCost); } } ################ TestInvoice.java ################### import java.util.Scanner; public class TestInvoice { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // creating three methods Invoice i1 = new Invoice(); Invoice i2 = new Invoice(); Invoice i3 = new Invoice();
  • 6. // input for first invoice System.out.print("Enter name of invoice1: "); i1.setName(sc.next()); System.out.print("Enter item number: "); i1.setItemNumber(sc.nextInt()); System.out.print("Enter quantity: "); i1.setQuantity(sc.nextInt()); System.out.print("Enter price: "); i1.setPrice(sc.nextDouble()); System.out.println(); // input for second invoice System.out.print("Enter name of invoice2: "); i2.setName(sc.next()); System.out.print("Enter item number: "); i2.setItemNumber(sc.nextInt()); System.out.print("Enter quantity: "); i2.setQuantity(sc.nextInt()); System.out.print("Enter price: "); i2.setPrice(sc.nextDouble()); System.out.println(); // input for third invoice System.out.print("Enter name of invoice3: "); i3.setName(sc.next()); System.out.print("Enter item number: "); i3.setItemNumber(sc.nextInt()); System.out.print("Enter quantity: "); i3.setQuantity(sc.nextInt()); System.out.print("Enter price: "); i3.setPrice(sc.nextDouble()); System.out.println(); sc.close(); // displaying three invoice information
  • 7. i1.displayLine(); System.out.println(); i2.displayLine(); System.out.println(); i3.displayLine(); System.out.println(); } } /* Sample Output: Enter name of invoice1: Invoice1 Enter item number: 123 Enter quantity: 21 Enter price: 34.56 Enter name of invoice2: Invoice2 Enter item number: 124 Enter quantity: 25 Enter price: 43.5 Enter name of invoice3: Invoice3 Enter item number: 125 Enter quantity: 27 Enter price: 65 Name: Invoice1 Item Number: 123 Quantity: 21 Price: 34.56 Total Cost: 725.76 Name: Invoice2 Item Number: 124 Quantity: 25 Price: 43.5 Total Cost: 1087.5 Name: Invoice3 Item Number: 125 Quantity: 27 Price: 65.0