Soru şu:
The store manager has asked you to write a computer program to produce a bill for a customer. The unit prices and the codes of the items are as follows:
Item Item Code Unit Price
Table t/T $25
Chair c/C $18
The program should input
-the item code
The program should compute and output the customer's bill and the item count. Also, display an error message for an incorrect item code. In the end of the program, press 'c' to continue to shopping or press any key to exit.
Write your code by using:
1 . If statement
2 . Switch statement
Sample execution is:
Enter the code of the item: t
Subtotal: 25
Press 'c' to continue, press 'e' to exit: c
Enter the code of the item: c
Subtotal: 43
Press 'c' to continue, press 'e' to exit: c
Enter the code of the item: T
Subtotal: 68
Press 'c' to continue, press 'e' to exit: e
In your shopping list there are 3 items.
The bill is: 68
Press any key to continue . . .
Yazdığım kod da bu
Kod:
#include #include int main ( void ) else if ( code== 't' || code== 'T') else printf("\nPlease enter a valid item code"); printf("\nPress 'c' to continue, press 'e' to exit:"); do while( cont == '\n' ); printf("\n"); } while( cont == 'c' || cont == 'C' ); printf("\nIn your shopping list there are %d items.", counter); printf("\nThe bill is: %d", sum); system ("PAUSE"); return ( 0 ); }
İlk seferde calışıyor duzgun sonra c karakterini girip devam edildiğinde "Enter the code of the item:" print edip hemen "Please enter a valid item code" print edip devam edip etmek istemediğini soruyor ama sorun nerede bulamadım.
__________________
C dersi odevimde takıldım
Android & IOS Uygulama Geliştirme0 Mesaj
●23 Görüntüleme
- ReadBull.net
- Programlama ve Yazılım
- Android & IOS Uygulama Geliştirme
- C dersi odevimde takıldım