Java programmming- help initialize(carpet)
<p>I have started how to learn Java programming and I a got a problem while doing an asignment:
ps this is a c programming assignment, using it to do a java programming:</p>

<blockquote>
  <p>Consider a (potentially large commercial) room that has floor dimensions length len and width wid. The area of the floor is given by multiplying len by wid.</p>
  
  <p>Carpet tiles are provided as individual squares (2 feet by 2 feet). Write, compile and run a C program, carpet.c, that</p>
  
  <p>-calculates the minimum number of carpet tiles that are needed to cover a room whose dimensions (len and wid) are input from the terminal (measurements are in inches). NB: floor tiles can be cut to fit at the edges of the room - try to minimise waste.</p>
  
  <p>-calculates how many carpet-tile packs are needed. The supplier only provides carpet tiles in packs of ten (i.e. individual tiles cannot be purchased separately).</p>
  
  <p>-calculates how many spare tiles are left over once the minimum number of packs have been purchased.</p>
  
  <p>-prints out all these results in a neat table along with the total cost of the order. (A pack of tiles costs $50 for each of the first four packs, and the price reduces to $45 for each subsequent pack.) </p>
  
  <p>Think carefully about how are you going to test your program? The calculations are non-trivial and easy to get wrong. If your program doesn't work then you will waste the company a lot of money and you will probably lose the contract to supply the software.</p>
  
  <p>You should write out a number of test cases (by hand) that cover all the different possibilities that could happen. Don't forget to consider various boundary cases too - these are often where errors are detected.</p>
</blockquote>

<p>So far I have done:</p>

<pre><code>import java.util.Scanner;

public class carpet {
    public static void main (String args[]){
    Scanner scanf = new Scanner (System.in);

        float len, wid;
        float area;

        int roundTiles;
        int roundPacks;

        float tarea;
        float tpack;
        float NoOfTiles;
        float NoOfPacks;
        float tspares1;
        float tspares2;
        int packCost;
        int cost;

        tarea= 12* 12;
        tpack= 10;

        System.out.format("Enter the length of the room, Inches: ");
        len = scanf.nextFloat();

        System.out.format("Enter the width of the room, Inches: ");
        wid = scanf.nextFloat();

        area = len * wid;

        NoOfTiles = area/ tarea;
        NoOfPacks = NoOfTiles/tpack;


        roundTiles = (int) Math.ceil(NoOfTiles);
        roundPacks = (int) Math.ceil(NoOfPacks);



        tspares1 = roundPacks * 10;
        tspares2 = tspares1 - roundTiles;

        if (roundPacks &lt;= 4)
            packCost =50;
        else if(roundPacks &gt; 4)
        {
            packCost = 45;
            packCost = packCost + 20;   *&lt;&lt;-----******LINE 50-----*********

        }


        cost =roundPacks * packCost; *&lt;&lt;*******---ERROR-------------*********

        System.out.println(cost);

        }

}
</code></pre>

<p><strong>The error says:</strong> <em>"The local variable packCost may not have been initialized"</em></p>

<p><strong>AND the compiler says:</strong> <em>"Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    The local variable packCost may not have been initialized
    at carpet.main(carpet.java:50)
"</em></p>
