please need this java program done with good programming sty


please need this java program done with good programming style and comments ASAP!

2, wniz a daa cailal Sheffing Ilag ketrakef imes pereaacL ibe shipingle need srea addtnal metheds a place itars is the begardto esapet the burhanet sat gurglue anties the eel crer of itors purchned nefm taxis te otal ater tas, tw namber erians in the bug, and the avenge ant caine Creale he frd knwinE rter fae and as it when ir letering the sawnga Ecless public inmee Reul deale RealKad(); Naal cad Efillers befan tax inable AveraeKlad(); aaverage condurasim hefae tax duble ToalCadix ooa, cost afal iris l int Totallest Ontnhepiens inthe bag B. Crease a class called implements the Retail inkrla class re-wen side bu% Atribeles cdach an object inclakteamber of items it bage die wa and b b. Crease a Mhad called Buzy hd pus ea sam iso the bug, lia-cepa an int rpricit indicating the qualityedind ali kebleegar-tandom he atifteina.Ferexample, inyBng.hms. 10 300 nepresm hoist swe

Solution

package example;


import com.sun.corba.se.impl.io.TypeMismatchException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;

/**
*
* @author Rashmi Tiwari
*/

interface Retail{
double retailCost(); //Retail cost of item before tax
double averageCost(); //Average cost of an item before tax
double totalCost(); //total cost of all items after tax
int totalItems(); //numbersof items in bag
}

class ShoppingFlag implements Retail{
  
private int numberOfItems; //Quantity of Items   
private double taxRate; //Tax Rate
private double retailCost; //Retail Cost
private double averageCost; //Average cost
private double totalCost; //Total Cost
private String itemName; //Item Name
private static double total; //Total varaible to find sum of all the items cost
private static int count=0; //Number of items
  
ShoppingFlag(double taxRate){ //Constructor as Tax Rate argument
this.taxRate=taxRate;
}
  
public int getNumberOfItems() { //Getter setter for Variables
return numberOfItems;
}

public void setNumberOfItems(int numberOfItems) {
this.numberOfItems = numberOfItems;
}

public double getRetailCost() {
return retailCost;
}

public void setRetailCost(double retailCost) {
this.retailCost = retailCost;
}

public String getItemName() {
return itemName;
}

public void setItemName(String itemName) {
this.itemName = itemName;
}
void buy(int numberOfItems,double retailCost){
this.numberOfItems=numberOfItems;
this.retailCost=retailCost;
}
  
public String toString(){ //Overirding of ToString method for Print Object\'s Value
return \"Items: \"+numberOfItems+\"\ Retail Cost: \"+retailCost()+\"\ Average Items Cost:\"+averageCost()+\"\ Total Cost including tax (\"+taxRate+\"):\"+totalCost();
}

@Override
public double retailCost() {
return retailCost;
}

@Override
public double averageCost() {
return total/count;
}

@Override
public double totalCost() {
return ((taxRate*total)/100)+total;
}

@Override
public int totalItems() {
return numberOfItems;
}
  

  

public static void main(String args[]){

ShoppingFlag item = new ShoppingFlag(7);

try {
List<String> items = Files.readAllLines(java.nio.file.Paths.get(\"./items.txt\"), StandardCharsets.UTF_8); //Reading values from File

for (String i: items){
String[] tokens = i.split(\" \");//Read all values in a line seperated by space

  
item.setItemName(tokens[0]);
item.setNumberOfItems(Integer.parseInt(tokens[1])); //conversion of string to int
item.setRetailCost(Double.parseDouble(tokens[2])); //conversion of sting to double
total+=Double.parseDouble(tokens[2]);
count++;
}

System.out.println(item.toString());
}catch (TypeMismatchException e) { //exception handing if data comes in wrong format
e.printStackTrace();
}
catch (IOException e) { //exception handing if checked exception is there
e.printStackTrace();
}

}
  
  
}

 please need this java program done with good programming style and comments ASAP! 2, wniz a daa cailal Sheffing Ilag ketrakef imes pereaacL ibe shipingle need
 please need this java program done with good programming style and comments ASAP! 2, wniz a daa cailal Sheffing Ilag ketrakef imes pereaacL ibe shipingle need
 please need this java program done with good programming style and comments ASAP! 2, wniz a daa cailal Sheffing Ilag ketrakef imes pereaacL ibe shipingle need

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site