2012-04-27 39 views
-4

我想讓程序開發數學探針,以便我的用戶可以回答它們。我自己運行程序,它顯示的按鈕讓我點擊它們的數字越來越多。任何人都可以請幫我解決這個問題。我所關心的程序部分是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++; 
       } 
      } 

     } 
    } 

} 

回答

2

您是否錯過了{}最近的else的正文?

+0

沒有沒有工作 – 2012-04-27 21:24:19

+0

但你明白爲什麼嗎? – sinelaw 2012-04-27 21:25:03

相關問題