Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
## TimberCo
Obuds2020 is a wood based business which specializes in sourcing and selling different kinds of wood.
Currently their focus is on softwood and hardwood.
The woods are categorized according to the dimensions as :
A-1X1",<br>
B-1X2",<br>
C-2X2",<br>
D-2X3",<br>
E-3X3",<br>
F-3X4",<br>
G-4X4",<br>
H-1X6",<br>
I-2X6",<br>
J-3X6"<br>
## The selling price per foot of the
dimension categories, A,B,C,D,E,F,G,H is based on the cost of A according to the rules:
Cost of B=A +30%A,<br>
Cost of C=B +30%B,<br>
Cost of D=C +30%C,<br>
Cost of E=D +30%D,<br>
Cost of F=E+30%E,<br>
Cost of G=F +20%F, <br>
Cost of H=G +20%G. <br>
 The cost of A may be reset from time to time if it becomes necessary.
The selling price per foot for J and that of I are related by Cost of J=I +50%I. The cost for I may be
reset from time to time if it becomes necessary.
At all times the selling price per foot is 100% of the purchase price per foot from the supplier.
Hardwood is always 200% more costly that softwood at the supplier point and 220% more costly at the
selling point.
# Requirements
## You are required to well commented abstract a class with with relevant data and methods to make it
possible to:
1. Generate a report on sales for each category of wood.
2. Generate a report on stock at any one period of time.
3. Generate a report on profit earned by a sale for each category of wood.
4. Generate a report on total profit made.
5. Draw a UML diagram of the abstract class
## Write well commented program ( main calss) that make use of the above class and also use the
following programming construct:
• Paramerised constructor
• A method that receives an object and then process the profit made
• Use of Math.random() method to generate lengths of feet sold
• A method that receives an array of objects and then process the sales made
• A method that creates an array of objects sold and return the array
## Deliverable
1. A pdf document that contains the entire program and the UML diagram and the output results


What I have tried:

public static void main(String[] args){   
    
    int[] my_array1 = {
            1789, 2035, 1899, 1456, 2013, 
            1458, 2458, 1254, 1472, 2365, 
            1456, 2165, 1457, 2456
         };
            
    String[] WoodType = {
           "A-1X1",
	   "B-1X2",
	   "C-2X2",
	   "D-2X3",
	   "E-3X3",
	   "F-3X4",
	   "G-4X4",
	   "H-1X6",
	   "I-2X6",
	   "J-3X6"
        };        
    System.out.println("Original numeric array : "+Arrays.toString(my_array1));
    
    System.out.println("Original string array : "+Arrays.toString(WoodType));
    double costA = 300.0;
        
    if (WoodType[1] == "A") {
        costA = 300;
      }
      else if(WoodType[1] == "B") {
        int costB = costA + 0.3(costA);
      }
      else if(WoodType[1] == "C") {
        int costC = costB + 0.3(costB);
      }
      else if(WoodType[1] == "D") {
        int costC = costC + 0.3(costC);
      }
      else if(WoodType[1] == "E") {
        int costE = costD + 0.3(costD);
      }
      else if(WoodType[1] == "F") {
        int costF = costE + 0.3(costE);
      }
      else if(WoodType[1] == "G") {
        int costG = costF + 0.3(costF);
      }
      else if(WoodType[1] == "H") {
        int costH = costG + 0.3(costG);
      }
      else if(WoodType[1] == "I") {
        int costI = costH + 0.3(costH);
      }
      else if(WoodType[1] == "J") {
        int costJ = costI + 0.3(costI);
      }
      // checks if number is less than 0
      
      
      // if both condition is false
      else {
        System.out.println("The number is 0.");
      }
      final int NUM_DAYS = 30; // Number of days of sales
      String filename;         // The name of the file to open
      double totalSales;       // Total sales for period
      double averageSales;     // Average daily sales
      
      // Get the name of the file.
      filename = getFileName();
      
      // Get the total sales from the file.
      totalSales = getTotalSales(filename);
      
      // Calculate the average.
      averageSales = totalSales / NUM_DAYS;
      
      // Display the total and average.
      displayResults(totalSales, averageSales);

      public static double getTotalSales(String filename)
      throws IOException
{
double total = 0.0;  // Accumulator
double sales;        // A daily sales amount

// Open the file.
File file = new File(filename);
Scanner inputFile = new Scanner(file);

// This loop processes the lines read from the file,
// until the end of the file is encountered.
while (inputFile.hasNext())
{
// Read a double from the file.
sales = inputFile.nextDouble();

// Add sales to the value already in total.
total += sales;
}

// Close the file.
inputFile.close();

// Return the total sales.
return total;
}
Posted
Updated 28-Nov-20 6:30am

You forgot to ask a question. However I see a few problems without running your code. In the cost adding code you have lines like:
Java
else if(WoodType[1] == "B") {
  int costB = costA + 0.3(costA);
}

But the variable costB only exists within that block so as soon as you get to the end of these tests it will no longer exist. You also have
Java
else if(WoodType[1] == "D") {
  int costC = costC + 0.3(costC);
}

which should probably be costD

But then you never do anything with these values so it is not clear what they are there for. I think what you actually need is a single variable that gets the cost of wood type A and then gets incremented by the various factors as you check its type.

But, more importantly, you have ignored the first requirement of your assignment:
You are required to well commented abstract a class with with relevant data and methods
 
Share this answer
 
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
And I'll give you a big hint: read the question again - there are bits you absolutely have to do that you've totally ignored in what you have done so far. For example:
Quote:
You are required to well commented abstract a class with with relevant data and methods to make it possible to ...
You haven;t constructed a class at all, let alone an abstract one!

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900