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

Exer

The document contains a Java class named 'Exer' that manages item purchase details including item name, price, quantity, and total cost. It includes methods for setting item details, calculating total cost, reading user input, and displaying output. There are some minor errors in variable naming and formatting within the methods.

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)
70 views1 page

Exer

The document contains a Java class named 'Exer' that manages item purchase details including item name, price, quantity, and total cost. It includes methods for setting item details, calculating total cost, reading user input, and displaying output. There are some minor errors in variable naming and formatting within the methods.

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

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([Link]);
[Link]("Enter the name of the item you are purchasing.");
itemName = [Link]();

[Link]("Enter the quality and price seperated by a space.");


itemquantity = [Link]();
itemPrice = [Link]();
}

public void writeOutput() {


[Link]("You are purchasing " + "(s) at" + itemPrice + "each.");
[Link]("Amount due is" + amountDue);
}
}

You might also like