なぜ初期化されていないと言っているのかわかりませんが、私は明らかに、そのchar typeOfWash, tireShine;
行でそうしましたよね?入力が「g」、「G」、「p」、または「P」でない限り、私のコードは問題なく機能します。typeOfWash ==の場合、「無効な選択」を出力する場合の最後のケースは入れていませんが、それは簡単で、後でドロップします。
#include <stdio.h>
int main()
{
//variable declarations
char typeOfWash, tireShine;
//Menu
printf("R ---> Regular ($5.00)\n");
printf("B ---> Bronze ($7.50)\n");
printf("G ---> Gold ($10.25)\n");
printf("P ---> Platinum ($15.00)\n");
printf("Tire Shine can be added to the Gold or Platinum ONLY,");
printf("for an additional$2.50\n\n");
printf("Enter your selection: ");
scanf("%c",&typeOfWash);
switch (typeOfWash)
{
case 'R': case 'r':
printf("Your bill total is: $5.00\n");
break;
case 'B': case 'b':
printf("Your bill total is: $7.50\n");
break;
case 'G': case 'g':
printf("Would you Like a Tire Shine? (Y/N): ");
scanf("%c",tireShine);
if (tireShine == 'Y' || tireShine == 'y')
printf("Your bill total is: $12.75");
else
printf("Your bill total is: $10.25");
break;
case 'P': case 'p':
printf("Would you Like a Tire Shine? (Y/N): ");
scanf("%c",tireShine);
if (tireShine == 'Y' || tireShine == 'y')
printf("Your bill total is: $17.50");
else
printf("Your bill total is: $15.00");
break;
}
return 0;
}