I am having trouble with layout, I know I am close. /// I have two errors that are (31,18): error CS1002: ; expected & (31,13): error CS1525: Invalid expression term 'else' /// I have tried to do what was said and it made more errors, so I am totally don’t know how to make this work now.
At the moment I have this
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));
}
}
}
I am trying to do this
**Write a program, for the local swimming pool that displays the admission cost for a group of people based on their age. The program should continue to prompt the user to enter an age until –1 is entered, and then display the total number of people in the group and the total cost for that group. Admission fees are as follows:
– under 16’s £2.50 over 65 -£3 and all other swimmers – £5
A 20% discount should be applied to groups of more than 6 people.**
This is connected to another cs called Program.cs, laid out like this and works, because I have tested with other cs files, this displays the program
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();
}
}
}
Thanks again, if anyone can help
Try this: