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

  • Home
  • SEARCH
  • 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 8707603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:54:39+00:00 2026-06-13T03:54:39+00:00

I need to make a loop that runs for 3 times and a switch

  • 0

I need to make a loop that runs for 3 times and a switch for three age groups 0-10 11-20 and 21-65 with the following code:

class Program
    {
        private static object N;
        static void Main(string[] args)
        {
            string answer;                                   
            {
              Console.WriteLine("please enter your name:");
              string name = Console.ReadLine();

              Console.WriteLine("please enter your surname:");
              string surname = Console.ReadLine();

              Console.WriteLine("please enter your age:");
              string age = Console.ReadLine();        

              Console.WriteLine("please enter your adress:");
              string adress = Console.ReadLine();

              Console.WriteLine("hallo,{0} {1},veel sucess met C#", name, surname);

              Console.WriteLine("zijn deze gegevens juist? J/N");
              answer = Console.ReadLine();
            }
            while(answer == "N");
        }
   }      

I tried some things to test the age, but I always got errors. Also, I don’t know how to write the loop code correctly.

Can somebody please point me in the right direction for both problems?

Sorry for my bad English I’m Dutch.

NOTE: the OP mentioned under one of the answers that this is not a homework assignment.

  • 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-06-13T03:54:41+00:00Added an answer on June 13, 2026 at 3:54 am

    Switch statements operate on specific values, not ranges, so you’d want to use a series if statements instead.

    Use a counter (declared outside of the loop and incremented on every execution) to determine how many times the loop has run (or use a for loop).

    Edit

    class Program
    {
        private static object N;
    
        static void Main(string[] args)
        {
            string answer;
            int runCount= 0;
    
            do
            {
              ++runCount;
              Console.WriteLine("please enter your name:");
              string name = Console.ReadLine();
    
              Console.WriteLine("please enter your surname:");
              string surname = Console.ReadLine();
    
              Console.WriteLine("please enter your age:");
              int age = int.Parse(Console.ReadLine());
    
              if(age >= 0 && age <= 10)
              {
                  Console.WriteLine("Child");
              }
              else if(age <= 20)
              {
                  Console.WriteLine("Young adult");
              }
              else if(age <= 65)
              {
                  Console.WriteLine("Adult");
              }
    
              Console.WriteLine("please enter your adress:");
              string adress = Console.ReadLine();
    
              Console.WriteLine("hallo,{0} {1},veel sucess met C#", name, surname);
    
              Console.WriteLine("zijn deze gegevens juist? J/N");
              answer = Console.ReadLine();
            }
            while(runCount < 3 && answer == "N");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program that runs with ROOT permission in Terminal following login
I need to make a loop that checks if an array ( $array ),
I need make some action (dump statistical data) before the Dart program ends. The
Need to make certain Ruby strings in my program to be immutable. What is
I need to make the top header of a report disappear. The part that
i have jquery code that loop through all checkboxes. $('input[type=checkbox]').each(function () { I now
I'm trying to make a loop that will recurse through an array of bytes
well, i make a loop that makes a lot of threads, see: foreach (DataGridViewRow
My C++ program has a main loop which runs until the program says it's
I'm trying to make a loop that will output this: 08:00 08:15 08:30 08:45

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.