Hello everyone I was making my task for school and I really don't understand the problem of my codes can anyone help me
school task:
Design a console application that calculates how much someone has to pay for a cinema ticket.
The full price of a cinema ticket is EUR 13.70.
Based on age, the price is determined:
Younger than 5: free;
Between 5 and 12: half price;
Between 13 and 54: full price;
55+: free
MY codes:
school task:
Design a console application that calculates how much someone has to pay for a cinema ticket.
The full price of a cinema ticket is EUR 13.70.
Based on age, the price is determined:
Younger than 5: free;
Between 5 and 12: half price;
Between 13 and 54: full price;
55+: free
MY codes:
C#:
//declaration variables
const double cdblFullPriceTicket = 13.70;
double dblEndPriceTicket;
int int Age;
dblEndPriceTicket = 0;
//entry
Console.Write("How old are you: ");
intAge = Convert.ToInt32(Console.Read()); ;
if (intAge < 5)
{
//output
Console.WriteLine();
Console.Write("your cinema ticket is free.");
}
else if (intAge >= 5 && intAge<= 12)
{
//calculation
dblEndPriceTicket = cdblFullPriceTicket / 2;
//output
Console.WriteLine();
Console.Write("you must pay " + Math.Round(dblEindPriceTicket, 2).ToString() + "EUR.");
}
else if (intAge >= 13 && intAge <= 54)
{
//calculation
dblEndPriceTicket = cdblFullPriceTicket;
//export
Console.WriteLine();
Console.Write("you must pay " + Math.Round(dblEindPriceTicket, 2).ToString() + "EUR.");
}
else if (intAge >= 55)
{
//output
Console.WriteLine();
Console.Write("your cinema ticket is free.");
}
else
{
Console.WriteLine();
Console.Write("you don't enter any data");
}
Console.ReadKey();
Last edited by a moderator: