8
Answers

How to iterate the loop as many times as the conversion is completed

How can I Iterate the loop as many times such that as if the conversion is completed & also I want to convert another value as many times as possible

Please find me the solution for this problem for the file named TempConverter.cs in the below Employee.rar File

Attachment: employee.rar

Answers (8)
1
Vulpes

Vulpes

NA 98.3k 1.5m 13y
{0:F2} means format what's in the first placeholder to 2 decimal places. So, if 'C' were 100, then it would format it as '100.00'.

{0} {1} means print what's in the first placeholder, followed by a space, followed by what's in the second placeholder. As you're only printing one number here, this would not be applicable.

Accepted
0
Senthilkumar

Senthilkumar

NA 15.2k 2.4m 13y
Hi,

Vulpes explained in the nice way.

Like this while(true)
       {

        }

you can use the following statement to infinite loop

for(;;)
{

}


0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 13y
Aditya, It seems you are not accepting the thread as Answer that helped you to resolve your problem. Its not a good practice, here we all are spending our time to help you. So Mark the thread as Answer, if it got resolved, so others can also get help from it.
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 13y
Vulpes, nice explanation..
0
Aditya Varma Mudunuri

Aditya Varma Mudunuri

NA 58 83.3k 13y
What is the meaning of this block {0:F2} in the above code because Generally we use {0} {1} like this to print the values in WriteLine Method

Why not the General one's cannot be worked out here in this example
0
Vulpes

Vulpes

NA 98.3k 1.5m 13y
Just change the Main() method to the following:

       static void Main(string[] args)
       {
          while(true) // loops indefinitely
          {
             Console.WriteLine("Select the Conversion Direction");
             Console.WriteLine("1.Celsius to FahrenHeit");
             Console.WriteLine("2.FahrenHeit to Celsius");
             Console.WriteLine("3.Exit application"); // need an exit route now
             Console.Write("You selected :");

             double F, C = 0;
             string selection = Console.ReadLine();
             Console.WriteLine();        
        
             switch (selection)
             {
                case "1":
                   Console.WriteLine("PLease Enter Celsius Temperature");
                   F = TempConverter.CelsiusToFahrenheit(Console.ReadLine());
                   Console.WriteLine("Temperature in FahrenHeit is {0:F2}",F); break;

                case "2":
                   Console.WriteLine("PLease Enter FahrenHiet Temperature");
                   C = TempConverter.FahrenheitToCelsius(Console.ReadLine());
                   Console.WriteLine("Temperature in Celsius is {0:F2}",C); break;
               
                case "3":
                   return; // returns from Main method and so exits application
 
                default:
                   Console.WriteLine("Please Select the Convertor");break;                   
             }

             Console.WriteLine();
          }
       }
0
Aditya Varma Mudunuri

Aditya Varma Mudunuri

NA 58 83.3k 13y
Now what my problem is after entering the celsius temperature the console quits the application whereas what i want is if any conversion or Viceversa is done even after it should return back to the console to take another conversion in the same console without rebuidling the application

Please Find me a solution.........................
0
Vulpes

Vulpes

NA 98.3k 1.5m 13y
You appear to have uploaded the wrong file.

The file you've uploaded is called EmpTax.cs, not TempConverter.cs.