私はJavaが初めてで、現在学期(CS Major)の最終プロジェクトに取り組んでおり、「変数が初期化されていない可能性があります」というエラーが発生しています。サイトで他の修正を試みましたが、それを行うたびに、作成したループで定義された変数ではなく、初期化された変数が使用されます。
public static void main(String[] args) {
double priceperpound = 2; // price per pound of coffee
int numberofbags = 2; // number of pounds of coffee
double bagweightinpounds = 1; // weight of the bag in punds
// double pricebeforetaxes = 8; // total before taxes
// double totalpricewithtaxes = 0; // total price
double taxrate = .065; // whats the tax?
double TotalWeight = 0; // total weight of purchase
// double discountprice = 0; // discounted price
// double discount = .9; // if you qualify the price before taxes will be multiplied by this
int row;
int col;
PriceCalculator calculations = new PriceCalculator(priceperpound, numberofbags,
bagweightinpounds, taxrate);
for (bagweightinpounds = 1; bagweightinpounds <= 5; bagweightinpounds = bagweightinpounds + 1) {
for (numberofbags = 2; numberofbags <= 1024; numberofbags = numberofbags * 2)
{
System.out.printf("%f", calculations.getBasePrice());
}
}
Scanner input = new Scanner(System.in);
}