mardi 19 septembre 2017

How to show a random number to 2 decimal places

I am making a program that generates a random number which then is shown to 2 decimal places, I have attempted this but it always comes up with an error.

This is my code:

Random r = new Random();
        double ran = r.Next();
        int egg;
        egg = Console.ReadLine;

        Console.WriteLine("The Random number is " + egg);


        egg = Convert.ToDouble(Console.ReadLine());

        Console.WriteLine(egg);
        Console.WriteLine(String.Format("price {0:C}", egg));


        Console.ReadLine();




Aucun commentaire:

Enregistrer un commentaire