-1
編寫一個程序,該程序將提示用戶輸入物品的價格和定價代碼。您的計劃應計算新的折扣價格並驗證輸入。從具有價格代碼的文章中找到折扣價格
本代碼中的一切都是正確的,但是當我運行編譯器時,我輸入了100的價格,但是然後這個CURSOR沒有停止在定價代碼上,我不能輸入我想要的定價代碼?爲什麼在'定價代碼'之後CURSOR不停止?
#include <stdio.h>
main()
{
float price, discp;
char code;
printf("Price Calculator");
printf("\n\n========================");
printf("\n\nEnter the price: $ ");
scanf("%f", &price);
printf("\n\nEnter the pricing code: ");
scanf("%c", &code);
if ((code=='C')||(code=='c'))
{
discp=price-0.3*price;
printf("\n\n\nNew discounted price is $%.2f\n\n\n\n\n\n\n", discp);
}
if ((code=='A')||(code=='a'))
{
discp=price-0.5*price;
printf("\n\n\nNew discounted price is $%.2f\n\n\n\n\n\n\n", discp);
}
if ((code=='B')||(code=='b'))
{
discp=price-0.4*price;
printf("\n\n\nNew discounted price is $%.2f\n\n\n\n\n\n\n", discp);
}
if ((code=='D')||(code=='d'))
{
discp=price-0.1*price;
printf("\n\n\nNew discounted price is $%.2f\n\n\n\n\n\n\n", discp);
}
if ((code=='E')||(code=='e'))
{
discp=price;
printf("\n\n\nNew discounted price is $%.2f\n\n\n\n\n\n\n", discp);
}
else
{
printf("\n\n\nInvalid Pricing Code\n\n\n\n\n\n\n", discp);
}
}