Below is my program... the whole purpose of this prog. is to ask user to enter product no. and then enter number of quantity he wants. When user input those two, he may want to order another product_no without having to terminate the program, so i used while loop != 'q' || !='Q'. The 'q' || 'Q' is for user who wants to end the loop and see the total price. When i run the program, and press q to end loop, the program has gone kindof bezerk. Kindly, plz help me out here with my prog.
#include<stdio.h>
main()
{
int Quantity, Product_No;
float Price, Total;
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf(" CareKidz \n");
printf(" Carrefour Subang Jaya \n");
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf("Welcome To CareKidz System!!\n");
printf("Make Your Selection from the menu below:\n\n");
printf("Product No.\tProduct\t\t\t\t\tPrice\n\n");
printf("\t1.\tPampers Baby Dry (Super Value Pack)\tRM 47.90\n");
printf("\t2.\tSumo Confort Super Value\t\tRM 28.90\n");
printf("\t3.\tPet-Pet Baby dry\t\t\tRM 17.90\n");
printf("\t4.\tChicolastic Ultra trim Jumbo\t\tRM 19.90\n");
printf("\t5.\tMamy Poko Disney\t\t\tRM 39.50\n");
printf("\t6.\tDryperss Wee-Wee Mega Pack\t\tRM 34.90\n");
printf("\t7.\tRoyale Kids Grace Kiki Lala Shoes\tRM 19.90\n");
printf("\t8.\tOK Baby Wear\t\t\t\tRM 25.90\n");
printf("\t9.\tWorld Of Cartoon Kids Wear\t\tRM 29.90\n");
printf("\t10.\tChristmas Teddy Bear\t\t\tRM 19.90\n");
printf("\n Type Q when you are finished with your selections.\n");
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@\n");
while ( Product_No != 'q'){
printf("Please enter a Product No. : ");
scanf("%d", &Product_No);
printf("Now enter the quantity you would like to purchase : ");
scanf("%d", &Quantity);
switch (Product_No) {
case 1:
Total = Quantity * 47.90;
break;
case 2:
Total = Quantity * 28.90;
break;
case 3:
Total = Quantity * 17.90;
break;
case 4:
Total = Quantity * 19.90;
break;
case 5:
Total = Quantity * 39.50;
break;
case 6:
Total = Quantity * 34.90;
break;
case 7:
Total = Quantity * 19.90;
break;
case 8:
Total = Quantity * 25.90;
break;
case 9:
Total = Quantity * 29.90;
break;
case 10:
Total = Quantity * 19.90;
break;
default:
printf("\nSorry, the Product No. you entered was not on the menu. Please try again!");
}
Price = Price + Total;
}
printf("\nTotal price for your order is %.2f", Price);
return 0;
}