我有练习/练习/家庭作业任务来创建一个 C# 程序来计算一个数字的值,该数字被提升到第二个数字的幂。从键盘上读取两个数字。
向用户询问一个整数。
将整数打印回屏幕并询问它是否正确。
如果整数正确,请继续。
如果整数不正确,从头开始启动程序。
我有两个问题:我可以以及如何以编程方式清除控制台窗口?
重新开始,我是调用 Main 方法还是 Class?我该怎么做,调用主方法或类?
这是我到目前为止所写的:
using System;
using System.Text;
namespace CalcPowerOfNums
{
class Program
{
//Declaring the two main string variables to be used in our calculation.
string firstUserString;
string secondUserString;
static void Main(string[] args)
{
//Ask the user for the first number.
Console.WriteLine("Enter your first number and press the Enter/Return key");
string firstUserString = Console.ReadLine();
//Make sure this number is correct.
Console.WriteLine("You want to find the power of {0}?\n" , firstUserString);
//Declaring, Initializing string variables for user answer.
string firstAnswer = "";
//Make user confirm or deny their choice.
Console.WriteLine("Press the lowercase letter y for yes");
Console.WriteLine("Press the lowercase letter n for no");
Console.ReadKey();
//If user answer is yes, move on… It user answer is no, start program over.
do
{
if (firstAnswer == "y")
continue;
if (firstAnswer == "n")
}