Question
Do in java My Code: package demo; interface Tax{ private static double middleEastTax = 0.15; private static double europe = 0.25; private static double canada
Do in java
My Code:
package demo;
interface Tax{ private static double middleEastTax = 0.15; private static double europe = 0.25; private static double canada = 0.22; private static double japan = 0.12; private static double debitCard = 0.02; private static double creditCard = 0.03; private static double other = 0.04; }
class PurchaseDetails{ private purchaseId = P1001; private String paymentType = Credit Card; this.purchaseId = purchaseId; this.paymentType = paymentType; public get String purchaseIDd() { return purchaseId; } public void set payment Type = (String purchaseId) this.purchaseId; public get String paymentType = paymentType(){ return paymentId; } public void set paymentType = (String paymentType) this.paymentType; }
}
public class PurchaseDetails {
private String location; private int price; this.location = location; this.price = price; public String location = location(){ return location; } public void setLocation = (location){ this.location; }
public int price = price(){ return price; } public void setPrice = (price){ this.price; } } class Tester{ public static void main(String args[]) { System.out.println("Purchase Details ***************"); PurchaseDetails purchaseDetails = new PurchaseDetails("P1001","Credit Card"); System.out.println("Total purchase amount: " + Math.round(purchaseDetails.calculateTax(100)*100)/100.0); System.out.println("Tax percentage: "+purchaseDetails.getTaxPercentage());
System.out.println("Seller Details ***************"); Seller seller = new Seller("Canada"); System.out.println("Tax to be paid by the seller: " + Math.round(seller.calculateTax(100)*100)/100.0); System.out.println("Tax percentage: "+seller.getTaxPercentage()); //Create more objects for testing your code } }
An e-commerce company has made it mandatory for all the customers to pay tax on every purchase and also for all the sellers to pay a certain amount of tax based on their location. You need to help the e- commerce company by implementing an application for paying tax based on the class diagram and description given below. calculate Tax(price double double Purchase Details purchaseld: String - payment Type: String ta Percentage double PurchaseDetails(purchaseld: String, payment Type: String) getPayment Type - String set Payment Type payment Types String} void getPurchased String setPurchaseld(purchased: String) void .getToPercentage double seta Percentage taxPercentage double} void calculateTaxprice: double double Seller location: String Percentage double Seller locationString) o getLocation: String SetLocation location String void o getTxPercentagelldouble set Percentage(tax Percentage: double) void o calculateTaxprice double double Method Description Purchase Details Purchase(String purchaseid, String paymentType) Initialize the purchaseld and paymentType instance variables using the values passed to the constructor. calculateTax(double price) . Initialize the value of the taxPercentage instance variable based on the details given below. Payment Type Tax (%) Debit Card 2 Credit Card 3 For all other payment types 4 Calculate and return the total amount (including the tax amount) that needs to be paid. Implement the getter and setter methods appropriately. Seller Seller(String location) . Initialize the location instance variable using the value passed to the constructor calculate Tax(double price) Initialize the value of taxPercentage instance variable based on the details given below. . Location Tax (%) Middle east 15 Europe 25Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started