2 番目の数値の累乗で数値を計算する C# プログラムを作成するための演習/ドリル/宿題があります。キーボードから 2 つの数字を読み取ります。
ユーザーに整数を尋ねます。
整数を画面に出力し、それが正しいかどうか尋ねます。
整数が正しい場合は、続行します。
整数が正しくない場合は、プログラムを最初から開始します。
2 つの質問があります。コンソール ウィンドウをプログラムでクリアできますか? また、その方法は?
最初からやり直します。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")
}