Advertisement
phoenix79194

Umsatzberechnung (1dArrays)

Apr 4th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Umsatz
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.        
  14.         // Vordefinierte Arrays
  15.  
  16.             int[] produktid = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
  17.             double[] plan = {800000,1258900,720000,550000,1200500,500000,300000,150000,700000,1200000,300000};
  18.             double[] ist = {900000, 2500000, 750000, 600000, 80000, 480000, 320000, 3000000, 450000, 900000, 330000 };
  19.                    
  20.             // Variablen
  21.  
  22.             int i;
  23.             double[] umsatz = new double[11];
  24.  
  25.             // Main
  26.          
  27.             Console.WriteLine("Willkommen liebe Manager!!");
  28.             Console.WriteLine("Wir berechnen hier unterschiedliche Werte für unsere Produkte.\n");
  29.  
  30.             for (i = 0; i <= 10; i++)
  31.             {
  32.                 umsatz[i] = ist[i] - plan[i];
  33.                 Console.WriteLine("Für Produkt {0} haben wir einen Plan-Umsatz von {1}$ und einen Ist-Umsatz von {2}$!\n", produktid[i], plan[i], ist[i]);
  34.  
  35.                 if (plan[i] <= ist[i])
  36.                 {
  37.                     Console.ForegroundColor = ConsoleColor.DarkGreen;
  38.                     Console.WriteLine("Der Umsatz wurde erreicht.");
  39.                     Console.WriteLine("Der Umsatz wurde um {0}$ überboten", umsatz[i]);
  40.                     Console.WriteLine("Das sind {0:F2}% mehr.", (ist[i] - plan[i]) * (100 / plan[i]));
  41.                     Console.ForegroundColor = ConsoleColor.White;
  42.                 }
  43.                 else
  44.                 {
  45.                     Console.ForegroundColor = ConsoleColor.Red;
  46.                     Console.WriteLine("Der Umsatz wurde nicht erreicht.");
  47.                     Console.WriteLine("Der Umsatz wurde um {0}$ unterschritten", -umsatz[i]);
  48.                     Console.WriteLine("Das sind {0:F2}% weniger.", -(ist[i] - plan[i]) * (100 / plan[i]));
  49.                     Console.ForegroundColor = ConsoleColor.White;
  50.                 }
  51.  
  52.                 if (umsatz[i] > 500000)
  53.                 {
  54.                     Console.ForegroundColor = ConsoleColor.Yellow;
  55.                     Console.WriteLine("Das Produkt ist ein A-Produkt!\n\n");
  56.                     Console.ForegroundColor = ConsoleColor.White;
  57.                 }
  58.                 else if (umsatz[i] > 0)
  59.                 {
  60.                     Console.ForegroundColor = ConsoleColor.Yellow;
  61.                     Console.WriteLine("Das Produkt ist ein B-Produkt!\n\n");
  62.                     Console.ForegroundColor = ConsoleColor.White;
  63.                 }
  64.                 else
  65.                 {
  66.                     Console.ForegroundColor = ConsoleColor.Yellow;
  67.                     Console.WriteLine("Das Produkt ist ein C-Produkt!\n\n");
  68.                     Console.ForegroundColor = ConsoleColor.White;
  69.                 }
  70.             }
  71.             Console.ReadKey(true);
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement