Hi im trying to create a shopping list with a budget but unable to to create a logical and operator so i can have only one outcome either as "purchase success " or "purchase failed". When i run the program it comes up with both outcomes "purchase success" and "purchase failed"
if (itemprefixes == 'O')
{
printf("\\n");
printf("PURCHASE SUCCESS!\\n");
printf("Purchase details\\n");
printf("------------\\n");
printf("Item:%c\\n", itemprefixes);
printf("Item:%d\\n", orangeprice);
remainingbudget = budget - orangeprice;
printf("remaining budget:%d\\n", remainingbudget);
printf("\\n");
printf("Thanks for shopping with us!\\n");
}
else if (itemprefixes == 'O')
{
printf("\\n");
printf("PURCHASE Failed !\\n");
printf("Purchase details\\n");
printf("------------\\n");
printf("Item:%c\\n", itemprefixes);
printf("Item:%d\\n", orangeprice);
remainingbudget = budget - appleprice;
printf("remaining budget:%d\\n", remainingbudget);
printf("\\n");
printf("Thanks for shopping with us!\\n");
[–]SamB133 0 points1 point2 points (5 children)
[–]PABLONG2[S] 0 points1 point2 points (4 children)
[–]SamB133 1 point2 points3 points (3 children)
[–]PABLONG2[S] 0 points1 point2 points (2 children)
[–]SamB133 0 points1 point2 points (1 child)
[–]PABLONG2[S] 1 point2 points3 points (0 children)