Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What do I need to change for my code to print?

I have created all the methods but for some reason when I run this code nothing prints. There are no error codes, it compiles fine but it just doesn’t print anything.

This is the driver code I am currently using.
`

public static void Main(string[] args)
        {
            
            Tree tree = new Tree(0);
            List<double>  list = new List<double>();
            for (int i= 0; i < list.Count; i++)
            {  double rain=   Driver.inchesRain(list);
                double rainMM= Driver.inchesToMM(rain);

                Console.WriteLine("Year " + i);
     
                Console.WriteLine("Rain this year: " + rain+" inches or "+rainMM +"mm");
                tree.grow(list[i]);
                tree.drawMe();
                Driver.fire(tree, list);

            }
        }

I have also tired to format it like this but this doesn't work either

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 public static void Main(string[] args)
        {
            
            Tree tree = new Tree(0);
            List<double>  list = new List<double>();
            for (int i= 0; i < list.Count; i++)
            { 
                Console.WriteLine("Year " + i);
                Console.WriteLine("Rain this year: " +  Driver.inchesRain(list)+" inches or "+Driver.inchesToMM(rain) +"mm");
                tree.grow(list[i]);
                tree.drawMe();
                Driver.fire(tree, list);

            }
        }

`

>Solution :

You just need to add some values to the list:

public static void Main(string[] args)
{
    Tree tree = new Tree(0);
    List<double>  list = new List<double>() {1.2, 2.3, 5.5}; //values added here
    
    for (int i= 0; i < list.Count; i++)
    {  double rain=   Driver.inchesRain(list);
        double rainMM= Driver.inchesToMM(rain);

        Console.WriteLine("Year " + i);

        Console.WriteLine("Rain this year: " + rain+" inches or "+rainMM +"mm");
        tree.grow(list[i]);
        tree.drawMe();
        Driver.fire(tree, list);
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading