Option yes/no C# Console

后端 未结 6 1406
暗喜
暗喜 2021-01-15 01:15

I\'m creating a C# program for the Currency Converter by console. At the end I would to insert \"Continue? (yes/no)\". Here the user have to chose. I\'ve tried this but it

6条回答
  •  不要未来只要你来
    2021-01-15 01:22

    you want something like that

    float Dollaro = 1.32f, Euro;
    float Cambio;
    string EuroStr;
    
         do
         {
            Console.Write("Euro: ");
            EuroStr = Console.ReadLine();
            Euro = float.Parse(EuroStr);
    
            Cambio = Dollaro * Euro;
    
            Console.WriteLine("Dollaro: " + Cambio);
            Console.WriteLine("Vuoi continuare? (yes/no)");
            Console.ReadLine();
            string risposta = Console.ReadLine();
    
                if (risposta.Equals("Y"))
                {
                    Console.WriteLine("Yes");
                    break;
                }
                else if (risposta.Equals("N"))
                {
                    Console.WriteLine("No");
                    break;
                }
    
          } while (risposta == "N");
    

    but that's just a sample, you need to give more information so i'll give you better example. what does your code supposed to do? what other option does the user have? and so on

提交回复
热议问题