Admin[dElmARk] Forum Owner
Posts : 78 EC-Points : 6304 Thanked : 21 Join date : 15/10/2011 Age : 29 Location : Philippines
Hacker's Info Hacking Exp: (0/0) Hacker Type: White Hat Hacking Title:
| Subject: Cashier Java Fri Nov 25, 2011 11:09 am | |
| - Code:
-
import java.util.*; public class Cashier { double cost; double tax; double payment; public static void main(String[] args) { Cashier app = new Cashier(); Scanner input = new Scanner(System.in); System.out.println("Please enter item cost: "); String i = input.nextLine(); app.setCost(Double.parseDouble(i)); System.out.println("The original cost of the item is: " +app.getCost()); System.out.println("The 6% sales tax of the item is: "); app.setTax(app.getCost() * 0.06); System.out.println("The total cost of the item is: " +(app.getCost() + app.getTax())); System.out.println("Enter the amount paid by the costumer: "); i = input.nextLine(); app.setPayment(Double.parseDouble(i)); if(app.getPayment() < app.getCost()+app.getTax()) { System.out.println("Your payment is not enough"); } else { double change = app.getPayment() - (app.getCost()+app.getTax()); System.out.println("Your change is: " + change); } } double getCost() { return cost; } double getTax() { return tax; } double getPayment() { return payment; } void setCost(double cost) { this.cost= cost; } void setTax(double taxRate) { tax=taxRate; System.out.println(tax); } void setPayment(double payment) { this.payment = payment; } }
|
|