Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7607679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:43:31+00:00 2026-05-31T00:43:31+00:00

i have done coding in C# but not much inside the Console App (teacher

  • 0

i have done coding in C# but not much inside the Console App (teacher is making us do an assignment in it)

I have a problem where my static method works fine the first time it is called (each question is asked), but the second time through the console closes. I need this function to execute 10 times and not sure why it wont. Here is what i have and thanks in advance!:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lab2
{
    class Program
    {
        //Create the arrays
        static string[] questions = new string[5];  //For questions
        static int[] tableHeader = new int[10];      //Table Header
        static int[,] responses = new int[5, 10];   //For answers

        //Int for the number of times the questions have been asked
        static int quizCount = 0;
        static int answer;
        static bool isGoing = true;

        static void Main(string[] args)
        {
            //Set the questions in an array
            questions[0] = "On a scale of 1-10, how do you feel about the drinking age in Wisconsin?";
            questions[1] = "On a scale of 1-10, how often do you drink a week?";
            questions[2] = "On a scale of 1-10, how important is this class?";
            questions[3] = "On a scale of 1-10, how would you rate this campus?";
            questions[4] = "On a scale of 1-10, how would you rate this command prompt?";
            while(isGoing)
                Questions();
        }

        static void Questions()
        {

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine(questions[i]);
                answer = Convert.ToInt16(Console.ReadLine());
                responses[i, quizCount] = answer;
            }
            if (quizCount < 10)
            {
                Console.WriteLine("Enter more data? (1=yes, 0=no)");
                int again = Console.Read();
                if (again != 1)
                    Environment.Exit(0);
            }
            else
                isGoing = false;
                DisplayResults();
        }

        static void DisplayResults()
        {
            Console.WriteLine(tableHeader);
            for (int i = 0; i < 5; i++)
            {
                for (int x = 0; x < 10; x++)
                {
                    Console.Write(responses[i, x]);
                }
                Console.Write("\n");
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:43:32+00:00Added an answer on May 31, 2026 at 12:43 am

    First off Console.Read() returns an int representing the ascii value of what was entered. If the user enters 1, Console.Read() returns 49. (See this ascii table)

    You could use Console.ReadKey()


    Second, you need some fixes in the way you loop and ask to continue….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have done jQuery and Ajax, but I am not able to get the
I have not done much database programming at all. I am working from some
i have done the coding to save the highscore in NSuserdefaults, but i am
I have never done any Windows coding and I would like to give it
I have done Java and JSP programming in the past, but I am new
I have done a little Django development, but it has all been in a
I have done a database diagram in Microsoft Visio but I don't know how
Ok, so I am wanting to write a calendar app, but I haven't done
I have done coding for mathematical simulation of Theory of Computation concepts in Python
I'm pretty new to cocoa and Xcode, I've done some basic C coding, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.