0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;  //first step add this 

namespace Project4
{
    class Program
    {
        static void Main(string[] args)
        {
            Random random = new Random();
            {
                int m = 0, j = 0, k = 0;
                Console.WriteLine("Enter Statet(m or j or  k)");
                String state = Console.ReadLine();
                {
                    m = random.Next(1,20);
                    Console.WriteLine(m + "\t" + m);
                    }
                if (state == "m")
                {
                    m = m + 1;
                }
                if (state == "j")
                {
                    j = j + 1;
                }
                else
                {
                    if (state == "k")
                        k = k + 1;
                }

                Console.WriteLine("The number of m is" + m);
                Console.WriteLine("The number of j is" + j);
                TextWriter frenchtoast = new StreamWriter("state.txt");
                frenchtoast.WriteLine(DateTime.Now);
                int rno = Convert.ToInt16(Console.ReadLine());

                switch (rno)
                {
                    case 1:
                        Console.WriteLine("California");
                        break;
                    case 2:
                        Console.WriteLine("Ohio");
                        break;
                    case 3:
                        Console.WriteLine("North Carolina");
                        break;
                }
            } string dummy = Console.ReadLine();
        }
    }
}

Edited by Reverend Jim: Fixed formatting

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Davenavie
0

I am trying here is where I'm at now:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;  //first step add this

namespace Project_4
{
    class Program
    {
        static void Main(string[] args)
        {
            Random random = new Random();
            int rno = 0;
            int m = 0;
            int j = 0;
            int k = 0;
            for (int i = 1; i <= 20; i++)
            {
                String state = Console.ReadLine();
                TextWriter frenchtoast = new StreamWriter("state.txt");
                frenchtoast.WriteLine(DateTime.Now);
                frenchtoast.Close();
                {
                    rno = random.Next(1, 6);
                    Console.WriteLine(i + "\t" + rno);
                }
                {
                    switch (rno)
                    {
                        case 1:
                            Console.WriteLine("California");
                            break;
                        case 2:
                            Console.WriteLine("Ohio");
                            break;
                        case 3:
                            Console.WriteLine("North Carolina");
                            break;
                            if (state == "m")
                            {

                                m = m + 1;
                            }
                            if (state == "j")
                            {
                                j = j + 1;
                            }
                            else
                            {
                                if (state == "k")
                                    k = k + 1;
                            }

                            Console.WriteLine("The State is California" + m);
                            Console.WriteLine("The State is Ohio" + j);
                            Console.WriteLine("The State is North Carolina" + k);
                    }
                }

            } string dummy = Console.ReadLine();
        }
    }
}

Edited by Reverend Jim: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.