using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Q216550
{
class Program
{
static void Main(string[] args)
{
double amount = 0.0;
int numberMembers = 0;
Console.Write("Enter the number of family members: ");
numberMembers = int.Parse(Console.ReadLine());
for (int i = 0; i < numberMembers; i++){
int age = -1;
while (age < 0 || age > 150) {
Console.Write("Enter the age for the member {0}: ", (i + 1));
age = int.Parse(Console.ReadLine());
}
double ticketPrice = 0;
if (age < 2)
{
ticketPrice = 50;
}
if (age >= 2 && age <= 12)
{
ticketPrice = 100;
}
if (age >= 13)
{
ticketPrice = 180;
}
Console.WriteLine("A bus ticket price is ${0}\n", ticketPrice);
amount += ticketPrice;
}
Console.WriteLine("\nThe total amount a family needs to pay for bus tickets: ${0}", amount);
Console.ReadLine();
}
}
}
Comments
Leave a comment