両方のループの合計値を比較することはできますか?
class Program
{
static void Main(string[] args)
{
int Op1_days = 0, Op1_salary = 0, Op2_days = 0, Op2_salary = 1, Op1_total = 0, Op2_total = 1;
Console.WriteLine("Option 1");
DisplayOption1(Op1_days, Op1_salary, Op1_total);
Console.WriteLine("\nOption 2");
DisplayOption2(Op2_days, Op2_salary, Op2_total);
{
Console.Write(Enter the option 1 total salary
}
static void DisplayOption1(int Op1_days, int Op1_salary, int Op1_total)
{
Console.WriteLine("Days Salary");
for (Op1_days = 1; Op1_days < 11; Op1_days++)
{
Op1_salary = Op1_salary + 100;
Console.WriteLine("{0} {1}", Op1_days, Op1_salary);
Op1_total = (Op1_total + Op1_salary);
}
Console.WriteLine("Total of option 1 salary is = {0} ", Op1_total);
}
static void DisplayOption2(int Op2_days, int Op2_salary, int Op2_total)
{
Console.WriteLine("Days Salary");
Console.WriteLine("1 1");
for (Op2_days = 2; Op2_days < 11; Op2_days++)
{
Op2_salary = Op2_salary * 2;
Console.WriteLine("{0} {1}", Op2_days, Op2_salary);
Op2_total = (Op2_total + Op2_salary);
}
Console.WriteLine("Total of option 2 salary is = {0} ", Op2_total);
}
}
合計を取得できますが、両方を比較することはできません。ループの最初の値を比較するだけです