Hey everyone, I am having difficulties getting my project to run correctly, when I run the code I only get one input box and none for the other strings
I am new to java programming if someone could test this on their compiler and perhaps suggest a fix It would be greatly appreciated
package robsproject;
import javax.swing.JOptionPane;
import java.io.*;
public class Amazon {
//Each output will have 5 different product fields: Productcode, Productdescription, inventorylevels, price, & cost.
//Part 1
public static String[] Productcode = new String[1000];
public static String[] Productdesc = new String[1000];
public static double[] price = new double[1000];
public static double[] cost = new double[1000];
public static double[] inv = new double[1000];
public static double[] retailvalue = new double[1000];
public static double[] profitvalue = new double[1000];
public static int count = 0;
public static int bookCount = 0;
public static int softwareCount = 0;
public static double totalInv = 0.0;
public static double totalValue = 0.0;
public static double totalProfit = 0.0;
public static double discount = 0.0;
public static void main(String[] args) throws IOException {
String fileName = "Amazonproductlist.txt"; //"C:\\datafiles\\products.txt" in java you need the \\
FileReader inputFile = new FileReader(fileName);
BufferedReader inputBuffer = new BufferedReader(inputFile);
//Header
String header = inputBuffer.readLine();
//System.out.println("Description Qty Price Cost Retail Value Profit Value ");
System.out.printf("%-10s %-20s %10s %10s %10s %15s %15s \n", "Code", "Description", "Price",
"Cost", "Qty", "Retail Value", "Profit Value");
//Body
String numString = inputBuffer.readLine();
while (numString != null)
{
String[] a = numString.split(",");
Productcode[count] = (a[0]).trim();
Productdesc[count] = (a[1]).trim();
price[count] = Double.parseDouble((a[2]).trim());
cost[count] = Double.parseDouble((a[3]).trim());
inv[count] = Double.parseDouble((a[4]).trim());
retailvalue[count] += price[count] * inv[count];
profitvalue[count] += (price[count] - cost[count]) * inv[count];
totalInv += inv[count];
totalValue += retailvalue[count];
totalProfit += profitvalue[count];
//to keep track of books and software:
if (Productcode[count].substring(0,1).equals("J"))
bookCount++;
else if (Productcode[count].substring(0,1).equals("N"))
softwareCount++;
//output the arrays
System.out.printf("%-10s %-20s %,10.0f %,10.2f %,10.2f %,15.2f %,15.2f \n", Productcode[count],
Productdesc[count], price[count], cost[count], inv[count], retailvalue[count], profitvalue[count]);
count++;
numString = inputBuffer.readLine();
}
inputBuffer.close();
//Footer
/*
The total number products read in was 42.
The total number of inventory items read in was 3800.
The total number books read in was 12.
The total number software read in was 30.
The total retail value of inventory is $397,455.00.
The total profit value of inventory is $197,455.00.
*/
System.out.println("The total number products read in was " + count);
System.out.println("The total number of book products read in was " + bookCount); //complete this System.out.println(bookCount); //complete this
System.out.println("The total number of software products read in was " + softwareCount); //complete this
System.out.println("The total number of inventory items read in was " + totalInv); //complete this or use below
System.out.printf("The total retail value of inventory is $%,.2f \n", totalValue);
System.out.printf("The total profit value of inventory is $%,.2f \n", totalProfit);
adjustPrice();
String strSearch = JOptionPane.showInputDialog("Enter code to search");
for (int i=0; i< count;i++)
{
if (strSearch.equals(Productcode[i])){
if (Productcode[i].equals(strSearch)){
System.out.println("Product Code:\t\t\t\t" +Productcode[i] + "\n" + "Description:\t\t\t\t" + Productdesc[i] + "\n" +
"Price:\t\t\t\t\t\t$" + Math.round(price[i] *100)/100.0 + "\n" + "Cost:\t\t\t\t\t\t$" + cost[i] + "\n" + "Inventory:\t\t\t\t\t" + inv[i]+ "\n"+
"Retail Value:\t\t\t\t$"+ totalValue+ "\n" + "Profit Value: \t\t\t\t$" + totalProfit);
}
}
}
}
private static void adjustPrice() {
}
}