Deklarata e problemit:
Jeni duke zhvilluar një chatbot duke përdorur JavaScript. Chatbot është i përkushtuar për të dhënë sugjerime buxhetore bazuar në vendin, llojin e mënyrës së transportit dhe llojin e akomodimit të nevojshëm. Akomodimi është i kategorizuar në 3 lloje
- Luksoze
- E moderuar
- Ekonomik
Pastaj mënyra e transportit janë 4 lloje
- Fluturimi
- Treni
- Autobus
- Makinë/ Biçikletë
Buxhetet për vendin e testimit janë të kategorizuara në 6 lloje tabelash/listash/detajesh
- Tavoline e gjitha luksoze
- Tavolinë luksoze
- Tabela e moderuar
- Tabela e ulët e moderuar
- Tabela ekonomike
- Tabela e rrugës
Nëse kushtet nuk funksionojnë me këto 6 kategori, duhet të shfaqet një mesazh përjashtimi siç jepet në kushtin më poshtë.
Shkruani kodin JavaScript për të zbatuar algoritmin për të buxhetuar planin për vendin (Ishulli i Shën Marisë)
Kushtet për t'u zbatuar:
/* Type of accommodation -> Luxury */ if( Bud1 >= '10,000' AND Tran1 = 'Flight' AND Type0 = 'Luxury') then category1= All Luxury table category2= Luxury table output= Table(category1) \\n; break; Table(category2) else if( Bud1>= '7,500' AND Tran1= 'Flight' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1>='5,000' AND Tran1= 'Flight' AND Type0='Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1>='2,500' AND Tran1= 'Flight' AND Type0='Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else output= 'No values to process' break; if( Bud1 >= '10,000' AND Tran1 = 'Bus' AND Type0 = 'Luxury') then category1= All Luxury table else if( Bud1 >= '7,500' AND Tran1 = 'Bus' AND Type0 = 'Luxury') then category1= Luxury table else if( Bud1 >= '5,000' AND Tran1 = 'Bus' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1 >= '2,500' AND Tran1 = 'Bus' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else output= 'No values to process' break; if( Bud1 >= '10,000' AND Tran1 = 'Train' AND Type0 = 'Luxury') then category1= All Luxury table else if( Bud1 >= '7,500' AND Tran1 = 'Train' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1 >= '5,000' AND Tran1 = 'Train' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1 >= '2,500' AND Tran1 = 'Train' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else output= 'No values to process' break; if( Bud1 >= '10,000' AND Tran1 = 'Car/Bike' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1 >= '7,500' AND Tran1 = 'Car/Bike' AND Type0 = 'Luxury') then category1= Luxury table else if( Bud1 >= '5,000' AND Tran1 = 'Car/Bike' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1 >= '2,500' AND Tran1 = 'Car/Bike' AND Type0 = 'Luxury') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else output= 'No values to process' break; /* Type of accommodation -> Moderate */ if( Bud1 >= '10,000' AND Tran1 = 'Flight' AND Type0 = 'Moderate') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1>= '7,500' AND Tran1= 'Flight' AND Type0 = 'Moderate') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1>='5,000' AND Tran1= 'Flight' AND Type0='Moderate') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else if( Bud1>='2,500' AND Tran1= 'Flight' AND Type0='Moderate') then output= 'Sorry! we can't plan with this combination, please change your preference to fit the trip with you budget' else output= 'No values to process' break; if( Bud1 >= '10,000' AND Tran1 = 'Bus' AND Type0 = 'Moderate') then category1= Luxury table category2= Moderate table category3= All luxury table output= Table(category1) \\n Table(category2) \\n Table(category3); else if( Bud1>= '7,500' AND Tran1= 'Bus' AND Type0 = 'Moderate') then category1= Luxury table category2= Moderate table category3= All luxury table output= Table(category1) \\n Table(category2) \\n Table(category3); else if( Bud1>='5,000' AND Tran1= 'Bus' AND Type0='Moderate') then category1= Moderate table category2= Lower Moderate table output= Table(category1) \\n Table(category2) \\n; else if( Bud1>='2,500' AND Tran1= 'Bus' AND Type0='Moderate') then category1= Lower Moderate table output= Table(category1) \\n; else output= 'No values to process' break;
Zgjidhja:
Ndani lidhjen tuaj të repo/codepen GitHub këtu për deklaratën e problemit në komente OSE më kontaktoni në [email protected]