// Author : Jake Rodriguez Pomperada
// Date : June 13, 2020 6:21 AM Saturday
// Website : www.jakerpomperada.com
// Email : jakerpomperada@gmail.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Grocery_Ordering_System
{
class Program
{
static void Main(string[] args)
{
int p0 = 0,p1 = 0,p2 = 0,p3 = 0,p4 = 0,p5 = 0,payment=0;
double sum = 0.00,total_cost = 0.00;
char decision;
double total_price = 0.00;
int[] final_qty = new int[100];
int[] product_number = { 0, 1, 2, 3, 4, 5 };
string[] product_title = { "Product Number", "Product Name", "Item Price" };
string[] product_title2 = { "Product Name", "Quantity", "Item Price", "Total Cost" };
string[] product_name = {"555 Tuna","Nido Milk", "Magic Flakes",
"Milo Mix","LuckyMe Noodles","Century Tuna"};
double[] item_price = {21.71,25.43,37.28,43.17,12.43,26.81};
do
{
Console.WriteLine("\n");
Console.WriteLine("\t\t===== Sally Grocery Ordering System in C# =====");
Console.WriteLine();
Console.WriteLine("\t" + product_title[0] + "\t" + product_title[1] + "\t " + product_title[2]);
Console.WriteLine();
for (int a = 0; a < product_name.Length; a++)
{
Console.WriteLine("\t\t" + product_number[a] + "\t" + product_name[a] + "\t " + item_price[a].ToString("00.00"));
}
Console.WriteLine();
Console.Write("\tSelect the Product Number to choose the Product : ");
int choose = Convert.ToInt32(Console.ReadLine());
Console.Write("\tHow many pieces? ");
int quantity = Convert.ToInt32(Console.ReadLine());
switch (choose)
{
case 0:
p0 += quantity;
final_qty[0] = p0;
break;
case 1:
p1 += quantity;
final_qty[1] = p1;
break;
case 2:
p2 += quantity;
final_qty[2] = p2;
break;
case 3:
p3 += quantity;
final_qty[3] = p3;
break;
case 4:
p4 += quantity;
final_qty[4] = p4;
break;
case 5:
p5 += quantity;
final_qty[5] = p5;
break;
}
Console.WriteLine();
Console.Write("\tWould you like to order again? Y/N : ");
decision = char.ToUpper(Console.ReadKey().KeyChar);
Console.WriteLine();
} while (decision != 'N');
Console.WriteLine("\n");
Console.WriteLine("\t===== FINAL PURCHASE =====");
Console.WriteLine("\t\t" + product_title2[0] + "\t\t" + product_title2[1]
+ "\t" + product_title2[2] + "\t" + product_title2[3]);
for(int i=0; i < final_qty.Length; i++)
{
if(final_qty[i] != 0)
{
double compute_two = final_qty[i] * item_price[i];
Console.WriteLine("\t\t" + product_name[i] + "\t\t "
+ final_qty[i] + "\t\t " + item_price[i].ToString("#####.00")
+ "\t\t PHP " + compute_two.ToString("#####.00"));
sum = sum + final_qty[i]*item_price[i];
}
}
Console.WriteLine();
Console.WriteLine("\tTotal Number of Purchased items: " + (p0 + p1 + p2 + p3 + p4 + p5));
Console.WriteLine();
Console.WriteLine("\tTotal Purchase PHP : " + sum.ToString("#####.00"));
do
{
Console.WriteLine();
Console.Write("\tEnter Your Payment PHP : ");
payment = Convert.ToInt32(Console.ReadLine());
}while(sum > payment);
double compute_all = (payment - sum);
Console.WriteLine();
Console.WriteLine("\tYour Change is PHP : "+ compute_all.ToString("#####.00"));
Console.WriteLine();
Console.WriteLine("\t\tThank you for buying at Sally's Grocery.");
Console.WriteLine();
Console.Write("\t\tEND OF PROGRAM");
Console.ReadKey();
}
}
} // End of Code