私は可能な限り試してみました。年金受給者の割引情報を出力していません。yを入力すると、費用はpensionerdiscountというラベルのプログラムの下部に表示されます。助けていただければ幸いです。ありがとうございます。プログラムの残りの部分が割引情報を出力していません
const int MaxRooms = 5; // max size of array needed
double[] roomCosts = new double[MaxRooms];
string pensioner; // Pensioner discount ? y for yes, n for no
int nRooms;
double area, mCost, lCost; // area, materials and labour costs
int i;
string customer;
double totalCost = 0.0;
double totallabour = 0.0; // calculated seperately to allow discount
const double setupCost = 30.00; // setup cost/room
double pensionerDiscountRate = 0.1; // 10% discount for pensioner
double discount, discountedTotal;
double[] basePrices = {0, 4.0, 8.0, 12.0 };
int jobType; // used to index basePrices
// prices per sq metre for paint only, paint+prep, prep+paper+paint
Console.Write("enter name of customer: ");
customer = Console.ReadLine();
Console.Write("\nenter number of rooms to quote for: ");
nRooms = Convert.ToInt32(Console.ReadLine());
Console.Write("\nPensioner discount (y/n) ? ");
pensioner = Console.ReadLine().ToUpper();
Console.WriteLine();
for (i = 0; i < nRooms; i++)
{
Console.Write("enter area for room {0}: ", i + 1);
area = Convert.ToDouble(Console.ReadLine());
Console.Write("enter job type for room {0} " +
"(1 - paint only, 2 paint+prep, 3 paint,prep+paper ", i + 1);
jobType = Convert.ToInt32(Console.ReadLine());
int newVariable = jobType + 1;
lCost = area * basePrices[newVariable] + setupCost; // labour cost
totallabour += lCost; // total labour cost separately
Console.Write("\nenter materials cost for room {0}: ", i + 1);
mCost = Convert.ToDouble(Console.ReadLine());
Console.WriteLine();
roomCosts[i] = lCost + mCost; // store labour and material costs for room
totalCost += roomCosts[i];
}
// main report heading
Console.WriteLine("Decorators R US Job Quotation");
Console.WriteLine("=============================");
Console.WriteLine();
Console.WriteLine("\nName of customer: {0}\n", customer);
Console.WriteLine();
Console.WriteLine("No. of rooms: {0}", nRooms);
// output subheadings
Console.WriteLine("Room\tCost\t%of Total");
for (i = 0; i > nRooms; i++)
{
Console.Write("{0}\t", i + 1);
Console.Write("£{0:0.00}\t", roomCosts[i]);
Console.WriteLine("{0:00.0}%", roomCosts[i] * 100/totalCost);
}
Console.WriteLine("Total Cost £{0:0.00}", totalCost);
if (pensioner == "y")
{
// deduct pensioner discount based on 10% of labour cost
discount = totallabour * pensionerDiscountRate;
discountedTotal = totalCost - discount;
Console.WriteLine("Pensioner Discount - £{0:0.00}", discount);
Console.WriteLine("Discounted Cost £{0:0.00}", discountedTotal);
Console.WriteLine();
}
Console.WriteLine("press enter to continue");
Console.ReadLine();
}
}
}