I am a bit stuck with this script. I am unable to improve the script to work as intended. If you help me out I will be very grateful.
Here is the program below:
namespace SpreadsheetFunctionality
{
class SpreedsheetFunctionality
static void Main(string[] args)
const int MAX_NUM_PRODUCTS = 100;
double [ ] retailPrices = new double[MAX_NUM_PRODUCTS];
string [ ] productNames = new string[MAX_NUM_PRODUCTS];
int numberOfProducts = 0;
int choice = 0;
productNames[0] = "Golden Apple Watch";
productNames[1] = "Swiss cuckoo clock";
productNames[2] = "ACME watch";
while (choice == 0)
Console.WriteLine("1. Add new product and price");
Console.WriteLine("2. Update existing product price");
Console.WriteLine("3. Calculate profits");
Console.WriteLine("4. Calculate totals");
Console.WriteLine("5. Exit");
Console.WriteLine("Enter your option: ");
int option = int.Parse(Console.ReadLine());
switch (option)
case 1:
Console.WriteLine("Enter the name of a new product in your catalogue");
for (int i = 0; i <1; i++)
productNames[i] = Console.ReadLine();
}
Console.WriteLine("Enter the price for it");
for (int i = 0; i < 1; i++)
retailPrices[i] = int.Parse(Console.ReadLine());
break;
numberOfProduct++;
case 2:
case 3:
Console.WriteLine("Enter the profit Percentage:");
int profitInPercent = int.Parse(Console.ReadLine());
for (int i=0; i<numberOfProduct; i++)
double salesProfits = (profitInPercent * retailPrices[i])/100;
Console.WriteLine("percentage :\t{0,8:c}", salesProfits);
Console.WriteLine("Products:");
case 4:
for (int j = 0; j<= retailPrices.Length ; j++){
retailPrices[j] += retailPrices[j + 1];
Console.Write("This is the tottal : ");
Console.WriteLine(retailPrices);
case 5:
System.Environment.Exit (-1); //to terminate the program
default:
Console.WriteLine("Invalid input!!");
public static string salesProfit { get; set; }
static int iCountval = 0; static void Main(string[] args) { const int MAX_NUM_PRODUCTS = 100; double[] retailPrices = new double[MAX_NUM_PRODUCTS]; string[] productNames = new string[MAX_NUM_PRODUCTS]; int numberOfProduct = 0; int choice = 0;
productNames[0] = "Golden Apple Watch"; retailPrices[0] = 100; productNames[1] = "Swiss cuckoo clock"; retailPrices[1] = 500; productNames[2] = "ACME watch"; retailPrices[2] = 600; iCountval = 3; while (choice == 0) { Console.WriteLine("1. Add new product and price"); Console.WriteLine("2. Update existing product price"); Console.WriteLine("3. Calculate profits"); Console.WriteLine("4. Calculate totals"); Console.WriteLine("5. All product Details"); Console.WriteLine("6. Exit");
Console.WriteLine("Enter your option: "); int option = int.Parse(Console.ReadLine());
switch (option) { case 1: Console.WriteLine("Enter the name of a new product in your catalogue"); productNames[iCountval] = Console.ReadLine(); Console.WriteLine("Enter the price for it");
retailPrices[iCountval] = int.Parse(Console.ReadLine()); iCountval = iCountval + 1; break; numberOfProduct++; case 2: Console.WriteLine("Enter product Name to Update : "); int index1 = Array.IndexOf(productNames, Console.ReadLine()); Console.WriteLine("Enter the price to Update : ");
retailPrices[iCountval] = int.Parse(Console.ReadLine());
break; case 3: Console.WriteLine("Enter the profit Percentage:"); int profitInPercent = int.Parse(Console.ReadLine());
for (int i = 0; i < iCountval; i++) {
double salesProfits = (profitInPercent * retailPrices[i]) / 100;
Console.WriteLine(productNames[i] + " is : percentage :\t{0,8:c} ", salesProfits);
Console.WriteLine("Products:"); break; case 4: Console.WriteLine("4. Calculate totals"); double calculatevalues = 0; for (int j = 0; j < iCountval; j++) { calculatevalues = calculatevalues+retailPrices[j]; } Console.Write("This is the tottal : "); Console.WriteLine(calculatevalues); break; case 5: Console.WriteLine("5. Details"); for (int j = 0; j < iCountval; j++) { Console.WriteLine("No." + j + "Product Name : " + productNames[j] + " Prize :" + retailPrices[j]); } break; case 6: Console.WriteLine("6. Exit"); System.Environment.Exit(-1); //to terminate the program break; default: Console.WriteLine("Invalid input!!"); break; } } }