You are on page 1of 1

import java.util.

*;

public class YourName {


String itemName;
double itemPrice;
int itemQuantity;
double amountDue;

Scanner s = new Scanner(System.in);


public void setItemName(String newItemName){
itemName = newItemName;
}
public String getItemName(){
return itemName;
}
public void setTotalCost(int quantity, double price){
itemQuantity = quantity;
itemPrice = price;
}
public double getTotalCost(){
return itemQuantity * itemPrice;
}
public void readInput(){
System.out.print("Enter the item name you are purchasing: ");
itemName = s.nextLine();
setItemName(itemName);

System.out.print("Enter item Quantity And Price: ");


itemQuantity = s.nextInt();itemPrice = s.nextDouble();

setTotalCost(itemQuantity,itemPrice);
}
public void writeOutput(){

System.out.print("You are purchasing " + itemQuantity + " " +


getItemName() + "(s)");
System.out.printf(" at a Total of $%.2f" , itemPrice );
System.out.print(" each");
System.out.println();
System.out.printf("Amount due is $%.2f", getTotalCost());
}
public static void main(String[] args) {
YourName You = new YourName();
You.readInput();
You.writeOutput();
}
}

You might also like