Wednesday, 2 June 2021

I want C programming for cancellation of reservation in flight please help

Im having a hard time on how to display the total price when i choose roundtrip, on how to display the price and the total price.. someone please help me pls pls pls Here are the requirements: A. Log in by Username and password B. User can choose either one way or roundtrip with selection of dates C. Flight options with different PRICES, SEATING CAPACITY and AVAILABLE SEATS. D. The user can book up to TEN TICKETS per transaction (even for different flights) E. Proper notifications or error messages must be observed like in the case where the user wants to book a flight with ZERO available seats, etc. F. Once all the tickets were booked, display a summary of the transaction including the TOTAL PRICE and TOTAL NUMBER OF TICKETS Your software must have the following: Basic I/O statements of C-language, Conditional Statements, Looping Statements, functions, arrays, strings, structures, pointers and memory allocation. You may include logical assumptions as part of your program. And here's my code so far #include #include #include void header() { printf("\nFlight Price Seating Capacity Available Seats\n"); } void option1() { printf("\nFlight Price Seating Capacity Available Seats\n"); printf("1. Manila To Hong Kong 1,500 100 16\n"); printf("2. Manila To Caticlan 1,000 75 0\n"); printf("3. Manila To Singapore 3,000 100 24\n"); } void option2() { printf("\nFlight Price Seating Capacity Available Seats\n"); printf("4. Manila To Hong Kong 1,700 100 18\n"); printf("5. Manila To Caticlan 2,000 75 24\n"); printf("6. Manila To Singapore 4,000 100 65\n"); } void option3() { printf("\nFlight Price Seating Capacity Available Seats\n"); printf("7. Manila To Hong Kong 2,000 100 46\n"); printf("8. Manila To Caticlan 1,500 75 16\n"); printf("9. Manila To Singapore 4,000 100 85\n"); } int choice() { } struct flight{ int ticket; int price; }; int main() { struct flight book[10]; char user[50], pw[50], adminu[50]="jon", adminpw[50]="snow"; int trip, date, date2, a, x, y; float total; char repeat; printf("\nEnter username: "); scanf("%s", &user); printf("\nEnter password: "); scanf("%s", &pw); if (strcmp(user, adminu)==0 && strcmp(pw, adminpw)==0) { printf("\nWelcome"); printf("\nChoose if one way trip or roundtrip: "); printf("\n1. One way trip \n2. Roundtrip\n"); scanf("\n%d", &trip); printf("\nDate: "); printf("\n1. August 10, 2017 \n2. August 11, 2017\n3. August 12, 2017(not applicable for round trip)\n"); scanf("%d", &date); switch (trip) { case 1: { if (date==1) { printf("\nAugust 10, 2017\n"); option1(); printf("\nHow many tickets will you get?:"); scanf("%d", &x); for (a=1; a<=x; a++) { printf("\nPlease select which flight you will book: "); scanf("%d", &book[a].ticket); } } else if (date==2) { printf("\nAugust 11, 2017\n"); option2(); printf("\nHow many tickets will you get?: "); scanf("%d", &x); for (a=1; a<=x; a++) { printf("\nPlease select which flight you will book: "); scanf("%d", &book[a].ticket); } } else if (date==3) { printf("\nAugust 12, 2017\n"); option3(); printf("\nHow many tickets will you get?: "); scanf("%d", &x); for (a=1; a<=x; a++) { printf("\nPlease select which flight you will book: "); scanf("%d", &book[a].ticket); } } else printf("\nInvalid"); break; } case 2: { if (date==1) { printf("\nAugust 10, 2017\n"); option1(); printf("\nChoose date of return: \n1. August 11, 2017\n2. August 12, 2017\n"); scanf("%d", &date2); printf("\nHow many tickets will you get (excluding the return trip)?: "); scanf("%d", &x); for (a=1; a<=x; a++) { printf("\nPlease select which flight you will book: "); scanf("%d", &book[a].ticket); if (date2==1) { switch (book[a].ticket) { case 1: { printf("\nDetails for return trip"); header(); printf("Hong Kong to Manila 2,000 100 45\n"); break; } case 2: { printf("\nDetails for return trip"); header(); printf("Caticlan to Manila 1,500 75 67\n"); break; } case 3: { printf("\nDetails for return trip"); header(); printf("Singapore to Manila 4,000 100 46\n"); break; } default: break; } } else if (date2==2) { switch (book[a].ticket) { case 1: { header(); printf("\nHong Kong to Manila 2,000 100 45"); break; } case 2: { header(); printf("\nCaticlan to Manila 1,500 75 67"); break; } case 3: { header(); printf("\nSingapore to Manila 4,000 100 46"); break; } default: break; } } else { printf("\nInvalid"); return 0; } } } else if (date==2) { printf("\nAugust 11, 2017\n"); option2(); printf("\nHow many tickets will you get?: "); scanf("%d", &x); for (a=1; a<=x; a++) { printf("\nPlease select which flight you will book: "); scanf("%d", &book[a].ticket); } } else if (date==3) { printf("\nAugust 12, 2017\n"); option3(); printf("\nHow many tickets will you get?: "); scanf("%d", &x); for (a=1; a<=x; a++) { printf("\nPlease select which flight you will book: "); scanf("%d", &book[a].ticket); } } else printf("\nInvalid"); break; break; } default: break; } printf("\n"); printf("\nSummary: "); for (a=1; a<=x; a++) { printf("\nDetails of Ticket no. [%d]", a); printf("\nFlight no. [%d]\n", book[a].ticket); } total=book[a].price; printf("\nTotal number of tickets: %d\n", x); printf("\nTotal Price: %0.2f", total); } else { printf("\nInvalid login"); } return 0; }

No comments:

Post a Comment

C Programming

What is DBMS in brief?

A Database Management System (DBMS) is a software suite designed to efficiently manage, organize, store, manipulate, and retrieve data. It a...