Untitled
unknown
plain_text
18 days ago
2.9 kB
3
Indexable
bool meny = true; bool fortsInst = true; bool fortsUttag = true; bool saldoKoll = true; bool ränta = true; string separera = "\n--------------------------------------"; string error = "Var vänlig kontrollera din inmatning."; string användarVal = "Vill du ta fortsätta, återgå till menyn eller avsluta? \n [M]eny \n [F]ortsätt \n [A]vsluta"; double insättning = 0.0; double uttag = 0.0; double ränteBetlng = 0.0; double totSaldo = 16753; while (meny) { Console.WriteLine(separera + "\n Bankkonto" + separera); //Meny Console.WriteLine(" [I]nsättning\r\n\r\n [U]ttag\r\n\r\n [S]aldo\r\n\r\n [R]äntebetalning\r\n\r\n [A]vsluta"); string AnvdrInput = Console.ReadLine().Trim().ToUpper(); Console.WriteLine(separera); switch (AnvdrInput) { //Insättning case "I": while (fortsInst == true) { try { Console.WriteLine("\n \nSaldo att sätta in: "); insättning = Convert.ToDouble(Console.ReadLine().Replace(".", ",")); //Korrigerar "." till "," if (insättning > 0) { totSaldo += insättning; //Uppdaterar totala saldot på kontot. Console.WriteLine("\n \nNytt saldo: " + totSaldo + ";-"); Console.WriteLine("\n"); Console.WriteLine(användarVal); string menyVal = Console.ReadLine().Trim().ToUpper(); if (menyVal == "M") { fortsInst = false; meny = true; } else if (menyVal == "F") { fortsInst = true; } else if (menyVal == "A") { fortsInst = false; meny = false; Console.WriteLine("Välkommen åter!"); break; } else { Console.WriteLine(error + " " + "'" + menyVal + "'" + " godkänns ej."); } } else { Console.WriteLine(error + " Var vänlig och kontrollera: " + insättning); } } catch (FormatException) //fångar felinmatningar. { Console.WriteLine(error); } } break;
Editor is loading...
Leave a Comment