A new shop named Healthy Fruits has opened in a town, suppose they have hired you as a software engineer to make a program for them to store fruits names with prices lists, as well as for them to keep track of their sales. The program should display the following Menu to users.
1. Insert/Store Fruits names and prices
2. Display the fruit’s list (Fruit names with Prices)
3. Buy Fruits
4. Display the Sales/Bills of customers who have bought fruitssert":"\n"}]}
#include <iostream>
#include <cstring>
using namespace std;
void main()
{
struct fruit
{
char fruitName[10];
float price;
};
struct customers
{
char fruitName[10];
float quantity_ordered;
float price;
float total_price;
};
char choice;
string fruit_choice;
float pounds_choice;
int count=0;
fruit fruits[5];
customer customers[5];
strcpy(fruits[0].fruitName, "Banana");
strcpy(fruits[1].fruitName, "Apple");
strcpy(fruits[2].fruitName, "Pears");
strcpy(fruits[3].fruitName, "Oranges");
strcpy(fruits[4].fruitName, "Papaya");
fruits[0].price=1;
fruits[1].price=2;
fruits[2].price=2.5;
fruits[3].price=1.5;
fruits[5].price=1.40;
strcpy(customers[0].fruitName, "Banana");
strcpy(customers[1].fruitName, "Apple");
strcpy(customers[2].fruitName, "Pears");
strcpy(customers[3].fruitName, "Oranges");
strcpy(customers[4].fruitName, "Papaya");
customers[0].price=1;
customers[1].price=2;
customers[2].price=2.5;
customers[3].price=1.5;
customers[4].price=1.40;
cout << "Welcome to the fruit market" << endl;
cout << "Would you like to purchase fruit?" << endl;
cin >> choice >> endl;
while (choice == 'Y')
{
cout << "Which fruit?" << endl;
cin >> fruit_choice >> endl;
cout << "How many pounds?" << endl;
cin >> pounds_choice >> endl;
if (fruit_choice == "Banana")
{
customers[0].quantity_ordered = pounds_choice;
customers[0].total_price = customers[0].quantity_ordered * customers[0].price;
}
else if (fruit_choice == "Apple")
{
customers[1].quantity_ordered = pounds_choice;
customers[1].total_price = customers[1].quantity_ordered * customers[1].price;
}
else if (fruit_choice == "Pears")
{
customers[2].quantity_ordered = pounds_choice;
customers[2].total_price = customers[2].quantity_ordered * customers[2].price;
}
else if (fruit_choice == "Oranges")
{
customers[3].quantity_ordered = pounds_choice;
customers[3].total_price = customers[3].quantity_ordered * customers[3].price;
}
else (fruit_choice == "Papaya")
{
customers[4].quantity_ordered = pounds_choice;
customers[4].total_price = customers[4].quantity_ordered * customers[4].price;
}
}
for (count = 1 ; count <=5 ; count++)
{
if (customers[0].total_price != 0)
{
cout << customers[0].fruit_name <<
cout << customers[0].quantity_ordered <<
cout << customers[0].price <<
cout << customers[0].total_price <<
}
}
}
Comments
Leave a comment