本文介绍了我13岁,刚接触编码。它会显示一条错误消息,说'}预期'请帮助!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.Write("what is your name?");
string name = Console.ReadLine();
Console.WriteLine("what is your age?");
try
{
int age = Convert.ToInt32(Console.ReadLine());
if (age == 13)
{
Console.WriteLine("I am " + age.ToString() + " too!");
Console.WriteLine("how are you?");
string mood = Convert.ToString(Console.ReadLine());
Console.WriteLine("So you're" + age + ". and your name is " + name + ". and you're current mood is " + mood + "? \n <yes or="">");
string yesno = Console.ReadLine();
if (yesno.ToLower() == "yes")
{
Console.WriteLine("Cool...");
Console.WriteLine("let's do some maths.");
Random numberGenerator = new Random();
int num01 = numberGenerator.Next(1, 11);
int num02 = numberGenerator.Next(1, 11);
Console.WriteLine("What is " + num01 + " times " + num02 + " ?");
int answer = Convert.ToInt32(Console.ReadLine());
if (answer == num01 * num02)
{
Console.WriteLine("Well done you know what " + num01 + " times " + num02 + " is! Congrats");
Console.WriteLine("<press the="" anykey="" to="" continue="">");
Console.ReadKey();
Console.WriteLine("Lets so some more...");
Random numberGenerator1 = new Random();
int num03 = numberGenerator1.Next(11, 31);
int num04 = numberGenerator1.Next(11, 31);
Console.WriteLine("What is " + num03 + " times " + num04 + " ?");
int answer1 = Convert.ToInt32(Console.ReadLine());
if (answer1 == num03 * num04)
{
Console.WriteLine("Well done you know what " + num03 + " times " + num04 + " is! Congrats");
Console.WriteLine("<press the="" anykey="" to="" continue="">");
Console.ReadKey();
Console.WriteLine("Lets so some more...");
}
else
{
Console.WriteLine("Go gack to school");
Console.WriteLine("<press the="" anykey="" to="" continue="">");
Console.ReadLine();
Random numberGenerator2 = new Random();
int num05 = numberGenerator1.Next(11, 31);
int num06 = numberGenerator1.Next(11, 31);
Console.WriteLine("What is " + num03 + " times " + num04 + " ?");
int answer2 = Convert.ToInt32(Console.ReadLine());
if (answer2 == num05 * num06)
{
Console.WriteLine("Well done you know what " + num05 + " times " + num06 + " is! Congrats");
Console.WriteLine("<press the="" anykey="" to="" continue="">");
Console.ReadKey();
Console.WriteLine("Lets so some more...");
}
}
else
{
Console.WriteLine("You lied to me...");
Console.WriteLine("<press the="" any="" key="" to="" exit="">");
Console.ReadKey();
}
}
else
{
Console.WriteLine("I am 13");
Console.WriteLine("how are you?");
string mood = Convert.ToString(Console.ReadLine());
Console.WriteLine("So you're " + age + ". and your name is " + name + ". and you're current mood is " + mood + "? \n <yes or="">");
string yesno = Convert.ToString(Console.ReadLine());
if (yesno.ToLower() == "yes")
{
Console.WriteLine("Cool...");
Console.WriteLine("let's do some maths.");
Random numberGenerator = new Random();
int num01 = numberGenerator.Next(1,11);
int num02 = numberGenerator.Next(1, 11);
Console.WriteLine("What is " + num01 + " times " + num02 + " ?");
int answer = Convert.ToInt32(Console.ReadLine());
if (answer == num01 * num02)
{
Console.WriteLine("Well done you know what " + num01 + " times " + num02 + " is! Congrats");
}
else
{
Console.WriteLine("Go gack to school");
Console.WriteLine("<press the="" any="" key="" to="" exit.="">");
Console.ReadLine();
}
Console.WriteLine("<press the="" any="" key="" to="" exit="">");
Console.ReadKey();
}
else
{
Console.WriteLine("You lied to me...");
Console.WriteLine("<press the="" any="" key="" to="" exit="">");
Console.ReadKey();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("You should have entered a number - go back to school...");
Console.WriteLine("<press the="" any="" key="" to="" exit="">");
Console.ReadKey();
}
}
}
}
推荐答案
if (answer2 == num05 * num06)
下面似乎缺少了closng大括号。
below seems to be missing closng brace.
else
{
Console.WriteLine("Go gack to school");
Console.WriteLine("<press the="" anykey="" to="" continue="">");
Console.ReadLine();
Random numberGenerator2 = new Random();
int num05 = numberGenerator1.Next(11, 31);
int num06 = numberGenerator1.Next(11, 31);
Console.WriteLine("What is " + num03 + " times " + num04 + " ?");
int answer2 = Convert.ToInt32(Console.ReadLine());
if (answer2 == num05 * num06)
{
Console.WriteLine("Well done you know what " + num05 + " times " + num06 + " is! Congrats");
Console.WriteLine("<press the="" anykey="" to="" continue="">");
Console.ReadKey();
Console.WriteLine("Lets so some more...");
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.Write("what is your name?");
string name = Console.ReadLine();
Console.WriteLine("what is your age?");
try
{
int age = Convert.ToInt32(Console.ReadLine());
if (age == 13)
{
Console.WriteLine("I am " + age.ToString() + " too!");
Console.WriteLine("how are you?");
string mood = Convert.ToString(Console.ReadLine());
Console.WriteLine("So you're" + age + ". and your name is " + name + ". and you're current mood is " + mood + "? \n ");
string yesno = Console.ReadLine();
if (yesno.ToLower() == "yes")
{
Console.WriteLine("Cool...");
Console.WriteLine("let's do some maths.");
Random numberGenerator = new Random();
int num01 = numberGenerator.Next(1, 11);
int num02 = numberGenerator.Next(1, 11);
Console.WriteLine("What is " + num01 + " times " + num02 + " ?");
int answer = Convert.ToInt32(Console.ReadLine());
if (answer == num01 * num02)
{
Console.WriteLine("Well done you know what " + num01 + " times " + num02 + " is! Congrats");
Console.WriteLine("");
Console.ReadKey();
Console.WriteLine("Lets so some more...");
Random numberGenerator1 = new Random();
int num03 = numberGenerator1.Next(11, 31);
int num04 = numberGenerator1.Next(11, 31);
Console.WriteLine("What is " + num03 + " times " + num04 + " ?");
int answer1 = Convert.ToInt32(Console.ReadLine());
if (answer1 == num03 * num04)
{
Console.WriteLine("Well done you know what " + num03 + " times " + num04 + " is! Congrats");
Console.WriteLine(""); Console.ReadKey(); Console.WriteLine("Lets so some more...");
}
else
{
Console.WriteLine("Go gack to school");
Console.WriteLine(""); Console.ReadLine();
Random numberGenerator2 = new Random();
int num05 = numberGenerator1.Next(11, 31);
int num06 = numberGenerator1.Next(11, 31);
Console.WriteLine("What is " + num03 + " times " + num04 + " ?");
int answer2 = Convert.ToInt32(Console.ReadLine());
if (answer2 == num05 * num06)
{
Console.WriteLine("Well done you know what " + num05 + " times " + num06 + " is! Congrats");
Console.WriteLine(""); Console.ReadKey(); Console.WriteLine("Lets so some more...");
}
else
{
Console.WriteLine("You lied to me...");
Console.WriteLine("");
Console.ReadKey();
}
}
}
else
{
Console.WriteLine("I am 13");
Console.WriteLine("how are you?");
string mood1= Convert.ToString(Console.ReadLine());
Console.WriteLine("So you're " + age + ". and your name is " + name + ". and you're current mood is " + mood + "? \n ");
string yesno1 = Convert.ToString(Console.ReadLine());
if (yesno1.ToLower() == "yes")
{
Console.WriteLine("Cool...");
Console.WriteLine("let's do some maths."); Random numberGenerator1 = new Random(); int num011 = numberGenerator1.Next(1, 11); int num021 = numberGenerator1.Next(1, 11);
Console.WriteLine("What is " + num01 + " times " + num021 + " ?");
int answer1 = Convert.ToInt32(Console.ReadLine());
if (answer1 == num01 * num021)
{
Console.WriteLine("Well done you know what " + num01 + " times " + num021 + " is! Congrats");
}
else
{
Console.WriteLine("Go gack to school"); Console.WriteLine(""); Console.ReadLine();
}
Console.WriteLine(""); Console.ReadKey();
}
else
{
Console.WriteLine("You lied to me...");
Console.WriteLine("");
Console.ReadKey();
}
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("You should have entered a number - go back to school...");
Console.WriteLine("");
Console.ReadKey();
}
}
}
}
这篇关于我13岁,刚接触编码。它会显示一条错误消息,说'}预期'请帮助!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!