レイアウトに問題があります。近くにいることはわかっています。/// 2つのエラーがあります(31,18): error CS1002: ; expected & (31,13): error CS1525: Invalid expression term 'else'
///言われたことを実行しようとしましたが、さらにエラーが発生したため、これを機能させる方法がわかりません。
現時点で私はこれを持っています
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CE0721a
{
class Tut4_7
{
public void run()
{
double under16_Free = 2.5;
double oap = 3.0;
double other = 5.0;
int groupSize = 0;
double totalCost = 0;
int age = 0;
while (age!=-1)
{
Console.WriteLine("Enter an Age or -1 to quit");
age=int.Parse(Console.ReadLine());
if(age<16)&(age>-1);
{
groupSize++;
totalCost = totalCost + under16_Free;
}
else if(age>16)
{
groupSize++;
totalCost = totalCost + oap;
}
else if(age>16)&(age<=65);
{
groupSize++;
totalCost = totalCost + other;
}
}
if (groupSize>6)
{
totalCost = totalCost - (totalCost/5);
}
Console.WriteLine("Total Cost = "(totalCost));
}
}
}
私はこれをやろうとしています
**年齢に基づいて人々のグループの入場料を表示する地元のスイミングプール用のプログラムを作成します。プログラムは、-1が入力されるまで年齢を入力するようにユーザーに促し続け、その後、グループ内の合計人数とそのグループの合計コストを表示する必要があります。入場料は次のとおりです。-16歳未満の場合65ポンド以上で2.50ポンド-£3および他のすべてのスイマー-£5
6人以上のグループには20%の割引を適用する必要があります。**
これは、Program.csと呼ばれる別のcsに接続されており、このようにレイアウトされて機能します。他のcsファイルでテストしたため、プログラムが表示されます。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CE0721a
{
class Program
{
static void Main(string[] args)
{
Tut4_7 myProgram = new Tut4_7();
myProgram.run();
}
}
}
誰かが助けることができれば、もう一度ありがとう