Jeg har brug for hjælp med at finde fejlen
hej folkens, jeg har brug for hjælp. Jeg er relativt set allerede færdig med min kode (dog mangler jeg stadig at skrive til fil etc men tager jeg bagefter) men lige ved endemålet går lortet galt:string adultTicketString;
int adultTicket = 0, childTicket = 0, childTicketPrice = 30, adultTicketPrice = 65;
int totalPrice = 0;
string AnswerMember;
int discountPrice = 0;
int discount;
string euroReply;
int totalTicket = 500;
int euroPrice = 0;
Console.WriteLine("Welcome to TEC Ballerup Stadium!\n" +
"Adult tickets are 65 DKK, children tickets are 30 DKK.\n" +
"You can buy a maximum of 10 children tickets and 10 adult tickets.\n" +
"A child can only enter with an adult, so the child ticket cannot be as big as the adult ticket.\n");
do
{
//purchase of adult ticket
Console.WriteLine("How many adult tickets do you want?\n ");
adultTicket = Convert.ToInt32(Console.ReadLine());
//if adult ticket is greater than 10 or less than 1 then the loop starts again
} while (adultTicket > 10 || adultTicket < 1);
if (adultTicket > 0)
{
do
{
//if child ticket is greater than 10 or less than 1 then the loop starts again
Console.WriteLine("\nHow many child tickets do you want?\n ");
childTicket = Convert.ToInt32(Console.ReadLine());
} while (childTicket > 10 || childTicket < 1);
}
totalPrice = (adultTicket * adultTicketPrice) + (childTicket * childTicketPrice);
{
Console.WriteLine("\nder is for "+ totalPrice+ " in dkk\n");
//ask for membership
Console.WriteLine("Are you a member? answer YES or NO");
AnswerMember = Console.ReadLine();
if (AnswerMember.ToUpper() == "YES")
{
Console.WriteLine("\nYou get 10% discount\n ");
discount = totalPrice * 10 / 100;
discountPrice = totalPrice - discount;
Console.WriteLine("The price with discount included is now " + discountPrice + "\n");
}
if (AnswerMember.ToUpper() == "NO")
{
Console.WriteLine("\nYou don't get any discount\n");
Console.WriteLine("the price without discount is" + totalPrice + "\n");
}
Console.WriteLine("Would you like to pay in Euro? answer YES or NO\n");
euroResponse = Console.ReadLine();
if (euroResponse == "YES")
{
Console.WriteLine("\nYou have chosen to pay with Euro\n ");
euroPrice = Convert.ToInt32(totalPrice * 0.13);
Console.WriteLine($"You must pay {euroPrice} EUR! ");
}
else if (euroReply == "NO")
{
Console.WriteLine($"You must pay {totalPrice * 0.13} DKK ");
}
Det går flydende igennem but så når man når til at brugeren skal type om de gerne vil have rabat og de siger ja så tæller min program det ikke med i min sidste euro og dkk pris. Hvordan kan det være? Er der en måde jeg kan fikse det uden at udslette noget af min kode? please hjælp