好吧,我为一些家庭作业编写了这个代码,我知道它可以被更好地修改,并且可以使用更多的评论,但是这个错误正在杀死我......想知道它只是我还是什么,但你能告诉我错误是否发生给你。
错误:读取类型没有任何数据。
(你现在可以只使用这些输入,因为我没有错误检查程序)测试变量:
2345 AA 20 30 40 50 60 10 R(应该输入)但程序跳过
假设为 rea_type 输入一个输入,但跳过它并继续到其他行。
这是代码:
const float deposit = 1500.00;
const unsigned multiplier =1;
const float rate_One = 6.350;
const float rate_Two = 14.520;
unsigned bill_Cycle = 0,
no_Days = 0;
float bi_Exch_Rate = 0,
ba_Exch_Rate = 0;
float cur_Read=0,
prev_Read=0,
cur_Usage=0,
cur_Peri_Charg=0;
char c_Digit[20],
premis_numb[20];
char rea_type;
/**Information to be collected from the user**/
system("cls");
printf("\nPlease enter the customer digits: ");
scanf("%s",&c_Digit);
printf("\nPlease enter Premise Number:");
scanf("%s",&premis_numb);
printf("\nPlease enter the Billing Cycle: ");
scanf("%d",&bill_Cycle);
printf("\nPlease enter the No. of Days: ");
scanf("%d",&no_Days);
printf("\nPlease enter the Billing Exchange Rate: ");
scanf("%f",&bi_Exch_Rate);
printf("\nPlease enter the Base Exchange Rate: ");
scanf("%f",&ba_Exch_Rate);
printf("\nPlease enter the Current Reading: ");
scanf("%f",&cur_Read);
printf("\nPlease enter the Previous Reading: ");
scanf("%f",&prev_Read);
printf("What is the Reading Type: ");
scanf("%c",&rea_type);
cur_Usage = cur_Read-prev_Read;
if (cur_Usage<100)
{
cur_Peri_Charg = cur_Usage*rate_One;
}
else
{
cur_Peri_Charg = (((cur_Usage-100) * rate_One)+(cur_Usage*rate_Two));
}
strcat(premis_numb,c_Digit);/**Joins the Premis Number and the Customer digits together**/
/**Information to be displayed showing user all input and calculations.**/
system("cls");
printf("\tStored constants for calculation of customer bill\n");
printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf(" Customer Number:%s",premis_numb);
printf(" Current Usage:%.2f \n",cur_Usage);
printf("\n");
printf(" Billing Cycle:%d\t\t No of Days:%d\n",bill_Cycle,no_Days);
printf("\n");
printf(" Billing Exchange Rate:%.2f Base Exchange Rate:%.2f\n",bi_Exch_Rate,ba_Exch_Rate);
printf("\n");
printf(" Deposit:%.2f\t\t Multiplier:%d\n",deposit,multiplier);
printf("\n");
printf(" Rate 1:%.3f\t\t Rate 2:%.3f\n",rate_One,rate_Two);
printf("\n");
printf(" Current Reading:%.2f\t Previous Reading:%.2f\n",cur_Read,prev_Read);
printf("\n");
printf(" Current Usage Reading:%.2f Reading Type:%c\n",cur_Peri_Charg,rea_type);
printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");