Advertisement
DerLyme

ParabolaChecker

Oct 21st, 2020
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ParabolaFinder
  4. {
  5.     class Calculator
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             bool close = false;
  10.             bool ask = false;
  11.             string answer;
  12.             double x, y;
  13.             double g;
  14.  
  15.             while (!close)
  16.             {
  17.  
  18.                 Console.WriteLine("Eingabe X-Koordinate: ");
  19.  
  20.                 x = Convert.ToDouble(Console.ReadLine());
  21.  
  22.                 Console.WriteLine("Eingabe Y-Koordinate: ");
  23.                 y = Convert.ToDouble(Console.ReadLine());
  24.  
  25.                 g = 0.9 * (x * x) + 1.3 * x - 0.7;
  26.  
  27.                 g = Math.Round(g, 1);
  28.  
  29.                 Console.WriteLine($"g = {g}");
  30.  
  31.                 if (g == y)
  32.                 {
  33.                     Console.WriteLine("Punkt ist auf Parabel!");
  34.                 }
  35.  
  36.                 else
  37.                 {
  38.                     Console.WriteLine("Punkt ist nicht auf Parabel!");
  39.                 }
  40.  
  41.                 do
  42.                 {
  43.                     Console.WriteLine("Neu starten? (Y/N)");
  44.                     answer = Console.ReadLine();
  45.  
  46.                     if ((answer.Equals("N", StringComparison.OrdinalIgnoreCase)))
  47.                     {
  48.                         close = true;
  49.                         ask = true;
  50.                     }
  51.  
  52.                     if ((answer.Equals("Y", StringComparison.OrdinalIgnoreCase)))
  53.                     {
  54.                         ask = true;
  55.                     }
  56.  
  57.                     if (!(answer.Equals("Y", StringComparison.OrdinalIgnoreCase)) && !(answer.Equals("N", StringComparison.OrdinalIgnoreCase)))
  58.                     {
  59.                         Console.WriteLine("Ungültige Eingabe");
  60.                     }
  61.  
  62.                 } while (!ask);
  63.             }
  64.         }
  65.     }
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement