纠正此程序中出现的错误 [英] rectify the error present in this program

查看:111
本文介绍了纠正此程序中出现的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

namespace feedbackformasp.net
{
    class Program
    {
        static void Main(string[] args)
        {
            string cont;
           do
           {

                Console.WriteLine("course list");
                Console.WriteLine("1.c#:2.asp.net:3.ado.net");
                //int ch= Convert.ToInt32 (Console.ReadLine());
            }
            here is the error 
switch (Convert.ToInt32(Console.ReadLine()))
            {
                case 1:
                Console.WriteLine("1. whether c# is too easy"+"\n"+"2.how many days coarse do u prefer"+"\n"+"3.which timings are preferable for u");
                    break;
                case 2:
                    Console.WriteLine("1.coarse duration"+"\n"+"2.timings"+"3.syllabus cover");
                        break;
                case 3:
                    Console.WriteLine("1.how do u feel ado.net"+"\n"+"2.thank you for ur interest");
                    break;
                default:
                    Console.WriteLine("wrong choice");
                    break;

            }
            Console.WriteLine("do u want to continue to continue ? (Y/N): ");
            cont = Console.ReadLine();
        while(cont=="Y"||cont=="y");
        Console.ReadLine();
       

        }
    }
}

推荐答案

我们不是做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



我们也不知道你认为什么这个程序中存在错误 - 从我的预期来看,它们有很多,但你不太可能发现其中任何一个!



亲自尝试,你可以发现它并不像你想象的那么困难!



但是......我会告诉你一个线索因为我怀疑你的问题 发现

do循环在哪里结束?并且它不在while...
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

We also have no idea what you consider "the error present in this program" - from my prospective there are loads of them, but you are not likely to have spotted any of those!

Try it yourself, you may find it is not as difficult as you think!

But...I'll give you a clue as the the problem I suspect you have spotted:
Where does the "do" loop end? And it's not at the "while"...


正确关闭关于do的大括号。



Close the braces regarding the "do" properly.

static void Main(string[] args)
        {
            string cont;
           do
           {

                Console.WriteLine("course list");
                Console.WriteLine("1.c#:2.asp.net:3.ado.net");
                //int ch= Convert.ToInt32 (Console.ReadLine());
            
          
switch (Convert.ToInt32(Console.ReadLine()))
            {
                case 1:
                Console.WriteLine("1. whether c# is too easy"+"\n"+"2.how many days coarse do u prefer"+"\n"+"3.which timings are preferable for u");
                    break;
                case 2:
                    Console.WriteLine("1.coarse duration"+"\n"+"2.timings"+"3.syllabus cover");
                        break;
                case 3:
                    Console.WriteLine("1.how do u feel ado.net"+"\n"+"2.thank you for ur interest");
                    break;
                default:
                    Console.WriteLine("wrong choice");
                    break;

            }
            Console.WriteLine("do u want to continue to continue ? (Y/N): ");
            cont = Console.ReadLine();
           }
        while(cont=="Y"||cont=="y");
        Console.ReadLine();


        }


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

namespace feedbackformasp.net
{
    class Program
    {
        static void Main(string[] args)
        {
            string cont;
            do
            {

                Console.WriteLine("course list");
                Console.WriteLine("1.c#:2.asp.net:3.ado.net");

                switch (Convert.ToInt32(Console.ReadLine()))
                {
                    case 1:
                        Console.WriteLine("1. whether c# is too easy" + "\n" + "2.how many days coarse do u prefer" + "\n" + "3.which timings are preferable for u");
                        break;
                    case 2:
                        Console.WriteLine("1.coarse duration" + "\n" + "2.timings" + "3.syllabus cover");
                        break;
                    case 3:
                        Console.WriteLine("1.how do u feel ado.net" + "\n" + "2.thank you for ur interest");
                        break;
                    default:
                        Console.WriteLine("wrong choice");
                        break;

                }
                Console.WriteLine("do u want to continue to continue ? (Y/N): ");
                cont = Console.ReadLine();
            }
            while (cont == "Y" || cont == "y");
            Console.ReadLine();


        }
    }
}


这篇关于纠正此程序中出现的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆