程序编译,但它不像我想要的那样表现

时间:2012-04-27 21:09:07

标签: c# android monodevelop xamarin.android

我正在努力让progam开发数学探针,以便我的用户可以回答它们。我自己运行程序,它显示按钮,让我点击它们上面的数字增加。任何人都可以帮我解决这个问题。我担心的程序部分是int Correctcount的结合。请帮忙

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

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;


namespace Jagtutor
{

    [Activity(Label = "Addition")]
    public class AdditionsActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Create your application here
            SetContentView(Resource.Layout.Second);

            var label = FindViewById<TextView>(Resource.Id.screen3Label);
            label.Text = Intent.GetStringExtra("ModuleData") ?? "Data not available";

            {
            int correctCount = 0;
            int count = 0;

                 while (count < 10);
                {
                    Random gen = new Random();
                    int num1 = gen.Next();
                    int num2 = gen.Next(); 


                    Console.Write("What is");
                    Console.Write(num1);
                    Console.Write( " - ");
                    Console.Write( num2);
                    Console.Write( "?");
                    int answer = Int32.Parse(Console.ReadLine());

                    if (num1 + num2 == answer) {
                        Console.Write(" Your are Correct!\n");
                        correctCount++;

                    }
                    else
                        Console.Write( "Your answer is wrong" );
                        Console.Write(num1);
                        Console.Write(" + ");
                        Console.Write(num2);
                        Console.Write("should be ");
                        Console.Write(num1 + num2);
                        count++;
                }
            }

        }
    }

 }

1 个答案:

答案 0 :(得分:2)

你可能会错过最近else身体的{}吗?