0% found this document useful (0 votes)
35 views1 page

Exer

Uploaded by

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

Exer

Uploaded by

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

public class Exer {

private String itemName;


private double itemPrice, amountDue;
private int itemQuantity;

public void setItemName(String newItemName) {


itemName = newItemName;
}

public void setTotalCost(int quantity, double price) {


itemPrice = price;
itemquantity = quantity;
}

public String getItemName() {


return itemName;
}

public double getTotalCost () {


amountDue = itemPrice * itemquantity;
return amountDue;
}

public void readInput () {


Scanner a = new Scanner(System.in);
System.out.println("Enter the name of the item you are purchasing.");
itemName = a.nextLine();

System.out.println("Enter the quality and price seperated by a space.");


itemquantity = a.nextInt();
itemPrice = a.nextDouble();
}

public void writeOutput() {


System.out.println("You are purchasing " + "(s) at" + itemPrice + "each.");
System.out.println("Amount due is" + amountDue);
}
}

You might also like