Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Posting again with error pic* I'm getting an error in KrisFlayer Class of this program. Kindly help me with that. Thanks Program.cs using System; namespace

*Posting again with error pic*

I'm getting an error in KrisFlayer Class of this program.image text in transcribed

Kindly help me with that. Thanks

Program.cs

using System; namespace Flight { class Program { static void Main(string[] args) { Console.WriteLine(" KrisFlyers Reward Discount System"); Console.WriteLine("Basic 10 %"); Console.WriteLine("Elite silver 20 %"); Console.WriteLine("Elite gold 30 %"); Console.WriteLine("Hello, Input based on your requirement"); Console.WriteLine("1.To input new entry"); Console.WriteLine("2.Display a single record:"); Console.WriteLine("3.Display all records"); Console.WriteLine("4.Exit"); KrisFlyer memberClass = null; var option = Convert.ToInt32(Console.ReadLine()); do { switch (option) { case 1: memberClass = CreateCustomer(); memberClass.CustomerList.Add(memberClass); break; case 2: Console.WriteLine("Enter the name of the customer"); var custName = Console.ReadLine(); if (memberClass == null) { Console.WriteLine("Customer does not exist"); } else { memberClass.display(custName); } break; case 3: if (memberClass == null) { Console.WriteLine("Customers don't not exist"); } else { memberClass.display(); } break; case 4: break; default: break; } Console.WriteLine("Hello, Input based on your requirement"); Console.WriteLine("1.To input new entry"); Console.WriteLine("2.Display a single record:"); Console.WriteLine("3.Display all records"); Console.WriteLine("4.Exit"); option = Convert.ToInt32(Console.ReadLine()); } while (option != 4); } public static KrisFlyer CreateCustomer() { KrisFlyer memberClass = null; Console.Write("Enter the name of the customer : "); var name = Console.ReadLine(); Console.Write("Enter the membership type: "); var membership = Console.ReadLine(); Console.Write("Enter the price for flight in dollars($) : "); var price = Convert.ToInt32(Console.ReadLine()); if (price

KrisFlyer.cs

using System; using System.Collections.Generic; namespace Flight { public class KrisFlyer { public string Name { get; set; } public string Membership { get; set; } public string Flight { get; set; } public int Price { get; set; } public int PassengerNumber { get; set; } public List CustomerList; public KrisFlyer(string name, string membership, string flight, int price, int passengerNumber) { Name = name; Membership = membership; Flight = flight; Price = Price; PassengerNumber = passengerNumber; CustomerList = new List(); } public virtual int GetDiscount() { return 0; } public void display() { Console.WriteLine("| Name | Price | No | Total | discount | Discounted Price |"); foreach (var customer in CustomerList) { Console.WriteLine(string.Format($"| {customer.Name} | {customer.Price} | {customer.PassengerNumber} | {customer.Name} | {customer.Price * customer.PassengerNumber}| {customer.GetDiscount()} | {customer.CalculateCost()} |")); } } public void display(string cust_name) { Console.WriteLine("| Name | Price | No | Total | discount | Discounted Price |"); var customer = CustomerList.Find(x => x.Name == cust_name); Console.WriteLine(string.Format($"| {customer.Name} | {customer.Price} | {customer.PassengerNumber} | {customer.Name} | {customer.Price * customer.PassengerNumber}| {customer.GetDiscount()} | {customer.CalculateCost()} |")); } public virtual double CalculateCost() { return Price * PassengerNumber; } } } Basic.cs namespace Flight { public class Basic : KrisFlyer { private readonly int _discount; public Basic(string name, string membership, string flight, int price, int passengerNumber, int discountValue ) : base(name, membership, flight, price, passengerNumber) { _discount = discountValue; } public override int GetDiscount() { return _discount; } public override double CalculateCost() { return Price * PassengerNumber *(1- (_discount / 100)); } } }

EliteSilver.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Flight { public class EliteSilver : KrisFlyer { private readonly int _discount; public EliteSilver(string name, string membership, string flight, int price, int passengerNumber, int discountValue) : base(name, membership, flight, price, passengerNumber) { _discount = discountValue; } public override double CalculateCost() { return Price * PassengerNumber * (1 - (_discount / 100)); } } }

EliteGold.cs

using System; using System.Collections.Generic; using System.Linq; namespace Flight { public class EliteGold : KrisFlyer { private readonly int _discount; public EliteGold(string name, string membership, string flight, int price, int passengerNumber, int discountValue) : base(name, membership, flight, price, passengerNumber) { _discount = discountValue; } public override double CalculateCost() { return Price * PassengerNumber * (1 - (_discount / 100)); } } }

Solution Explorer -- EliteGold.cs EliteSilver.cs Basic.cs KrisFlyer.cst X Program.cs Flight.KrisFlyer - GetDiscount TCILICH 23 public void display() 24 25 Console.WriteLine("| Name Price No | Total | discount | Discounted Price "); + foreach (var customer in Customerlist) 28 { 29 Console.WriteLine(string.Format($) {customer.Name} l {customer-Pricel {customer. Passenger Number} {customer. Name} {custom- 30 } 31 } | 1 reference 32 public void display(string cust_name) 33 34 Console.WriteLine("| Name Price | No | Total | discount | Discounted Price 1"); var customer = Customerlist.Find(x => x.Name == cust_name); 36 Console.WriteLine(string.Format($){customer.Name} h {customer Price lu{customer. Passenger Number) h customer.Name} li {customer. P 37 [ } 100 % Search Solution Explorer (Ctrl+;) Solution 'KrisFlyer' (1 project) C# KrisFlyer Properties - References App.config C# Basic.cs C# EliteGold.cs C# EliteSilver.cs C# KrisFlyer.cs C# Program.cs Error List XX Solution Explorer Team Explorer Class View X 18 Errors 10 Warnings D O Messages Search Error List Properties x Line 36 Column 45 46 234 Description 9 Invalid expression term X 10 ) expected 11 Invalid expression term ')' (X) 12 ; expected 13 Invalid expression term ')' X 14 ; expected 15 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement 16 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement 17 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement 18 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement Frror Mirt Outnut File Krishlyer.cs KrisFlyer.cs KrisFlyer.cs KrisFlyer.cs KrisFlyer.cs KrisFlyer.cs KrisFlyer.cs KrisFlyer.cs KrisFlyer.cs KrisFlyer.cs 36 36 36 36 36 29 29 36 36 234 235 235 50 238 46 Project KrisFlyer KrisFlyer KrisFlyer KrisFlyer KrisFlyer KrisFlyer Krisflyer KrisFlyer KrisFlyer KrisFlyer 234 Activate Windows Go to Settings to activate Windows

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago

Question

Understand the roles of signs, symbols, and artifacts.

Answered: 1 week ago

Question

Discuss the key ambient conditions and their effects on customers.

Answered: 1 week ago