Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

newbie problem

guys I'm a newbie studying c# at school and I got a problem that I just can't solve.

  class Program

  {


    static void Main(string[] args)

    {

       

      int fahrenheit;

      Console.WriteLine("Välkommen till bastun");

      Console.WriteLine("ange temp!");


      fahrenheit = int.Parse(Console.ReadLine());

      int celsius = Summa(fahrenheit);



      do

      {


        if (celsius > 77)

        {

          Console.WriteLine("för varmet ange ett annat nummer: ");


          Console.WriteLine(celsius);

          fahrenheit = int.Parse(Console.ReadLine());

          celsius = Summa(fahrenheit);


        }


        if (celsius < 72)

        {

          Console.WriteLine("för kallt ange ett annat nummer");



          fahrenheit = int.Parse(Console.ReadLine());

          celsius = Summa(fahrenheit);

        } 



      } while (celsius > 77 && celsius < 73 );



    }


    public static int Summa(int tal1)

    {

      int metod_svar = (tal1 - 32) * 5 / 9;

      return metod_svar;

    }


The code keep stepping out the loop somehow. Does anyone knows that the problem is? thank you!

    

Answers

  • COOLCODERCOOLCODER Member
    edited September 9

    enter Console.ReadKey(); at the end.

    this will make the program wait for the user to tap a key..

    if you dont enter it,it will close the program without waiting for a user input..

Sign In or Register to comment.