Question: Core Java_OOPS Concept_CC Problem 1 SendIt is a mid sized Logistics Company that connects Shippers with trusted Carriers aimed at making sending easier than ever.

Core Java_OOPS Concept_CC Problem 1

SendIt is a mid sized Logistics Company that connects Shippers with trusted Carriers aimed at making sending easier than ever. The Company uses two types of Invoices: Sales Invoice and Service Invoice and there are different types of tax imposed on each of these Invoices. For a Sales Invoice, the Company charges VAT tax and CST tax For a Service Invoice, there are two types of Service: Air Service and Land Service. For Air Service, the Company imposes Federal Excise tax For Land Service, the Company imposes Commercial tax.

Write a program using Multilevel Inheritance wherein Invoice is the parent Class, SalesInvoice and ServiceInvoice extends Invoice and in turn AirService and LandService extends ServiceInvoice. The program should calculate the tax amount and the total amount to be paid for each of type of Invoice. If its Service Invoice, consider whether its a land service or an air service.

Problem Specifications: [Note :Strictly adhere to the object oriented specifications given as a part of the problem statement.Use the same class names, attribute names and method names.] 1.Create a class named Invoice Include the following protected data members / attributes:

Integer id

Double amount

Include appropriate getters and setters and constructor. 2. Create a class named SalesInvoice that extends Invoice with following protected attributes,

Integer vatTaxPercentage

Integer cstTaxPercentage

Include appropriate constructor ( id, amount, vatTaxPercentage, cstTaxPercentage).

Include the following methods :

S.NO Method Name Method Description
1 void computeTax(Double amount) this method is to compute tax for SalesInvoice

3. Create a class named ServiceInvoice that extends Invoice

Include appropriate constructor( id, amount, serviceType).

4. Create a class named AirService that extends ServiceInvoice

Integer travelTaxPercentage

Include appropriate constructor( id, amount, serviceType, travelTaxPercentage).

Include the following methods :

S.NO Method Name Method Description
1 void computeTax(Double amount) this method is to compute tax for AirService

5. Create a class named LandService that extends ServiceInvoice with following attributes

Integer rentTaxPercentage

Include appropriate constructor( id, amount, serviceType, rentTaxPercentage).

Include the following methods :

S.NO Method Name Method Description
1 void computeTax(Double amount) this method is to compute tax for LandService

NOTE : Amount and tax should be in 2 decimal place.

Input and Output Format:

Refer sample input and output for formatting specifications. [All text in bold corresponds to input and the rest corresponds to output.] Sample Input and Output 1: Select the invoice type 1)Sales invoice 2)Service invoice 1 Enter the invoice id 1234 Enter the amount 1000.20 Enter the vat tax percentage 5 Enter the cst tax percentage 6 Tax to be paid for vat is 50.01 Tax to be paid for cst is 60.01 Total amount to be paid is 1110.22 Sample Input and Output 2: Select the invoice type 1)Sales invoice 2)Service invoice 2 Enter the service type 1)Air service 2)Land service Air service Enter the invoice id 1245 Enter the amount 1200.00 Enter the federal excise tax percentage 10 Tax to be paid for federal excise is 120.00 Total amount to be paid is 1320.00 Sample Input and Output 3: Select the invoice type 1)Sales invoice 2)Service invoice 2 Enter the service type 1)Air service 2)Land service Land service Enter the invoice id 1456 Enter the amount 2000.00 Enter the commercial tax percentage 10 Tax to be paid for rent is 200.00 Total amount to be paid is 2200.00

Here I am updating the codes. Please update it and send me back.

LandService.java

public class LandService extends ServiceInvoice{ Integer rentTaxPercentage; LandService(Integer id,Double amount,String serviceType,Integer rentTaxPercentage){ super(id,amount,serviceType); this.rentTaxPercentage = rentTaxPercentage; } void computeTax(Double amount){ //fill your code } }

SalesInvoice.java

public class SalesInvoice extends Invoice { Integer vatTaxPercentage; Integer cstTaxPercentage; SalesInvoice(Integer id,Double amount,Integer vatTaxPercentage,Integer cstTaxPercentage){ super(id,amount); this.vatTaxPercentage = vatTaxPercentage; this.cstTaxPercentage = cstTaxPercentage; } void computeTax(Double amount){ //fill your code } }

Invoice.java

public class Invoice { Integer id; Double amount; Invoice(){} Invoice(Integer id,Double amount){ this.id = id; this.amount = amount; } void setId(Integer id){ this.id = id; } Integer getId(){ return id; } void setAmount(Double amount){ this.amount = amount; } Double getAmount(){ return amount; } }

AirService.java

public class AirService extends ServiceInvoice { Integer travelTaxPercentage; AirService(Integer id,Double amount,String serviceType,Integer travelTaxPercentage){ super(id,amount,serviceType); this.travelTaxPercentage = travelTaxPercentage; } void computeTax(Double amount){ //fill your code } }

ServiceInvoice.java

public class ServiceInvoice extends Invoice {

String serviceType; ServiceInvoice(){} ServiceInvoice(Integer id,Double amount,String serviceType) { super(id,amount); this.serviceType = serviceType; }

}

Main.java

import java.io.*; public class Main { public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //fill your code } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!