
Hi can you help me I have to modify the program below so that all the data held in it is stored in an external text file.So there should not be any variables in the program which are assigned values like 12 or paint.The variables should be replaced by variables which get their values from at the start of the program from a seperate external text file.Thank you!
mport java.util.*; import java.text.*; import java.util.Scanner; class HardwareItems { String code; String description; double price,total; double vat=0.2; // variable declaration int weight,quantity,shipping, cost; // variable declaration
HardwareItems(String code,String description,double price){
this.code=code;
this.description=description;
this.price=price;
}
public String getCode(){
return code;
}
public String getDescription(){
return description;
}
public double getPrice(){
return price;
}
public static void main(String []args){
ArrayList<HardwareItems> list=new ArrayList<HardwareItems>();
list.add(new HardwareItems("K16","Wood screws,brass,20mm,50 grams",7.75));
list.add(new HardwareItems("D24","Wood glue,clear,1 liter,350 grams",5.50));
list.add(new HardwareItems("M93","Sandpaper,fine grade,50 grams",10.25));
list.add(new HardwareItems("M94","Sandpaper,fine grade,60 grams",14.75));
list.add(new HardwareItems("B21","Claw Hammer,1500 grams",13.50));
list.add(new HardwareItems("B35","Garden Shovel,2200 grams",15.00));
list.add(new HardwareItems("A10","Garden Hose,2100 grams",10.25));
list.add(new HardwareItems("A45","Hand Saw,1000 grams",12.75));
list.add(new HardwareItems("C51","Garden Fork,2400 grams",14.50));
DecimalFormat df=new DecimalFormat("$ ##.##");
System.out.println("Hardware Items");
System.out.println();
System.out.println("Code "+" Description "+" Unit Price ");
for(HardwareItems e : list){
System.out.println(e.getCode()+"\t"+e.getDescription()+"\t"+df.format(e.getPrice()));
}
Scanner in=new Scanner (System .in);
System.out.println("place your order!");
System.out.print("NAME:");
String l=in.nextLine();
System.out.print("ADDRESS-1:");
String m=in.nextLine();
System.out.print("ADDRESS-2:");
String n=in.nextLine();
System.out.print("ADDRESS-3:");
String o=in.nextLine();
System.out.print("POST CODE:");
String p=in.nextLine();
Scanner input=new Scanner(System.in);
System.out.print("Code:" );
String code=input.next();
System.out.print("Quantity: ");
int quantity=input.nextInt();
String check="";
while(!check.equals("no")){
System.out.print("Is there another Customer order?(yes/No) :");
check=input.next();
if(check.equals("yes")){
System.out.print("Code:" );
code=input.next();
System.out.print("Quantity: ");
quantity=input.nextInt();
}
else{
break;
}
}
}
}