0% found this document useful (0 votes)
20 views2 pages

Java Invoice Exercise

Uploaded by

heranialemu69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Java Invoice Exercise

Uploaded by

heranialemu69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

public class Invoice {

private String partNumber;


private String partDescription;
private int quantity;
private double pricePerItem;

public Invoice(String partNumber, String partDescription, int quantity, double


pricePerItem) {
this.partNumber = partNumber;
this.partDescription = partDescription;
this.quantity=quantity;
this.PricePerItem=pricePerItem;
}

public String getPartNumber() {


return partNumber;
}

public void setPartNumber(String partNumber) {


this.partNumber = partNumber;
}

public String getPartDescription() {


return partDescription;
}

public void setPartDescription(String partDescription) {


this.partDescription = partDescription;
}
public void setPricePerItem(double pricePerItem) {
if(pricePerItem > 0){
this.pricePerItem = pricePerItem:
}else{
this.pricePerItem = 0.0;
}
}
public double getPricePerItem() {
return pricePerItem;
}
public void setQuantity(int quantity) {
if(quantity>0){
this.quanity=quantity:
}else{
this.quantity=0:
}
}
public int getQuantity() {
return quantity;
}

public double getInvoiceAmount() {


return quantity * pricePerItem;
}

public static void main(String[] args) {


Invoice invoiceTest = new Invoice("typeA2", "chip", 10, 100);
System.out.println("Item's Part Number: " + InvoiceTest.getPartNumber());
System.out.println("Item's Part Description: " +
InvoiceTest.getPartDescription());
System.out.println("Item's Quantity: " + InvoiceTest.getQuantity());
System.out.println("Price per Item: $" +InvoiceTest.getPricePerItem());
System.out.println("Invoice Amount: $" + InvoiceTest.getInvoiceAmount());
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy