Making and cancelling reservations

I tried making a reservation program. however, i am not so conversant with using threads. the program is supposed to make a booking for a client. the client can make more than one booking and they can also cancel their booking(s). how can i achieve this using threads? the code i came up with is:
import java.util.Scanner;
public class Reserve
    private static int[] seats = new int[20];
    public static void main(String args[])
            for (int i = 0; i < 20; i++)
             seats[i] = 0;
             Scanner input = new Scanner(System.in);
               int choice = 1;
               System.out.print("Please enter 1 to book a seat or 2 to exit: ");
               choice = input.nextInt();
                while (choice != 2)
                   int seatnumber = 0;
                     // If they choose a seat, attempt to book it.
                     if (choice == 1)
                        seatnumber = bookseat();
                           // Booking a seat was successful.
                            System.out.println("You are in luck, we have a seat available!");
                            printBoardingPass(seatnumber);
                     else
                         // Print an error message if they did not choose 1 or 2 for their choice.
                         System.out.println("Invalid choice made.");
                         choice = 0;
                        // No seats were available.
                        if (seatnumber == -1)
                            System.out.println("We are sorry, there are no seats available.");
                            System.out.println();
                        // Reprompt for a choice
                        System.out.print("Please enter 1 book a seat, or 2 to exit: ");
                        choice = input.nextInt();
    // This function checks for seats and returns seat number or -1 if full.
    private static int bookseat()
        for (int i = 0; i < 20; i++)
            if (seats[i] == 0)
                seats[i] = 1;
                return i + 1;
        return -1;
    // This prints out a boarding pass message with their seat number
    private static void printBoardingPass(int seatnumber)
        System.out.println("Boarding pass for seat number: " + seatnumber);
}

timon_zed wrote:
would that apply to the use of threads or for a regular class? straight across the table. how can i develop something to develop a booking and cancellation program using threads? i was told i could make it easier to use if i made it using threads, but am just a newbie. so how, please how can i use threads for this program?Whoever told you that it would be easier to use threads, was wrong on two counts. First, it almost certainly won't be any easier. Secondly, you shouldn't use threads for that reason anyway.
If this is a homework assignment and if your teacher didn't tell you that you have to use threads, then don't. You're just making trouble for yourself.
If this is a homework assignment and if your teacher did tell you that you have to use threads, then tell us exactly what that requirement is. And don't be deceitful about it being homework; people around here usually don't want to do your homework for you, but there's a general willingness to help.
If this isn't homework, but a real world project to build some kind of booking system...then, threads may or may not enter into it. (Well, it would almost certainly enter into it in some sense, but chances are in the real world you'd use some kind of existing system that handles the multithreading for you.)

Similar Messages

  • How do I unsubscribe from Adobe Creative Cloud and cancel my Adobe ID? I tried going to "Cancel my membership" on their site but it just takes me in a full circle and I end up back at "Cancel my membership" again.  Is this a ploy to not let go of potentia

    How do I unsubscribe from Adobe Creative Cloud and cancel my Adobe ID? I have tried numerous times going to "Cancel my membership" on their site but it just goes through several steps and ends up where I began (i.e. Cancel my membership). Why is it so difficult to unsubscribe? Thks for any advice. Lavandula

    Adobe contact information will not help You. The Finnish sites are making the same loop. The worst thing is that they have send me e-post telling that my membership will continue after first year automatically with 60 % higher price. I don't need do anything I will not continue the membership. It seems impossible to end it. The onlys solution seems to be close the credit card.

  • Accidentally clicked "cancel reservation" in iPhone 4 confirmation email

    Anyone else have their reservation canceled by accidentally hitting the "cancel reservation" link at the bottom of the email? It shouldn't cancel it automatically, but it does.

    I actually did the same exact thing. Yesterday I had a reservation in New York and I cancelled it because I wanted to pick it up in DC. When I cancelled the reservation if prompted me asking if I was sure. Today I wanted to check the reservation for my DC reservationa and I clicked on the "Cancel Reservation" button and it immediately cancelled my reservation without prompt. I still have the confirmation email though, so hopefully they will still honor it. If not I will be pretty upset

  • Open and cancelled Quote Report

    Hi,
    Can anyone give me the information  for getting open and cancelled Quote Report?

    I hope you are using reason for rejection for cancelling quotations. If that is the case, you can use transaction VA25 to view the list of quotations. Here you can filter on two columns status and reason for rejection to view the report as per your requirement.
    Regards,
    GSL.

  • Mark waiting and cancelled tasks completed

    Hi All,
    is there sql somewhere that can mark certain tasks that are in waiting and canceled status to Completed?
    Thanx.
    Fred

    I would suggest using the APIs to update the status or use the manuallyComplete API instead.
    -Kevin

  • Repeated charges and cancelled charges

    What xxxxxxxxx is going on with automatic charges being put on my checking account, cancelled, and put on, and cancelled? This has been happening all day. This is happening at $25 per transaction.

    Davaronio wrote:
    This is happening at $25 per transaction.
    Hello and welcome to the Skype Community!
    According to your account it has also happened with $10 transactions.
    I'll check and advise. Sorry for the inconvenience.
    TIME ZONE - US EASTERN. LOCATION - PHILADELPHIA, PA, USA.
    I recommend that you always run the latest Skype version: Windows & Mac
    If my advice helped to fix your issue please mark it as a solution to help others.
    Please note that I generally don't respond to unsolicited Private Messages. Thank you.

  • Void and Cancelled Checks

    Hello All,
    What is the difference between void and cancelled checks?
    Thanks,
    Deki

    A voided cheque is one where the cheque number is marked as void but the payment document still exists. For example if a cheque was torn and you want to assign the payment to a different cheque.
    A cancelled cheque is when you did not intend to make that payment so you void the cheque and reversed the payment.

  • My iphone 4S has problem in making and receiving the calls. While making the call , call fails and netwrok disappears. Like wise no voice is heard for incoming calls. This happened after return from the overseas travel.

    My iphone 4S has problem in making and receiving the calls. While making the call , call fails and netwrok disappears. Like wise no voice is heard for incoming calls. This happened after return from the overseas travel.

    Hello SamSax
    Check out the assist page below for troubleshooting call connectivity.
    Calls and connection issues
    http://www.apple.com/support/iphone/assistant/calls/
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • Customer invoice doument and cancelled document are showing under openitems

    Dear All,
    I have created customer invoice in VF01 and cancelled the invoice in VF11.
    1.System is showing Invoice document and cancelled document under open items list in FBL5N customer line items.
    A. Is this correct?
            or
    B. When we cancelled the invoice document it should automatically go to cleared items list?
    Kindly provide me what is the correct?
    Thanks & Regards,
    Saisri.

    Hello,
    Once you cancelled the invoice document then you have to clear manually those items in tC: F-32. If you are not cleared then system will show you as open item. After cleared in F-32 then status will change from Open to Close.
    Thanks
    Para

  • Please help me understand making and loading variable classes

    Hi guys ,
    I know that I am stupid but I just can't get this!  AS3 says you need to load variables into a class?  Please please give me a simple example
    my variables look like this... (the whole point of playing around with variables was that if I had to make a change I could access one place and change them...
    but now I realse that I can't access or call them outside the movie clip they are in:(
    please hlep me!
    var ans1="";
    var ans2="";
    var w1="ABN";
    var def1="An ABN (Australian Business Number), is a personal number for your business that makes it easier and quicker to deal with  government and other businesses.";
    var w2="ACN";
    var def2="An ACN is an Australian Company Number, which is a special number that each company gets to identify it.  No two companies can have the same ACN";
    var w3="Action Plan";
    var def3="A business Action Plan will show What needs to be done and When it needs to be done by."
    var w4="Advertising";
    var def4="Advertising is producing information to let people know about your business and try to increase sales."
    var w5="Promotions";
    var def5="Promotions are where your business tries to increase the sales of a particular item through offering a good deal, advertising or a special display.";
    var w6="Benefit";
    var def6="A benefit is something good that you get.  One benefit of doing exercise is getting fit, another benefit is losing weight.";
    var w7="Business Mentor";
    var def7="A business mentor is a trusted guide. Someone who has experience and has been successful in business and can help and advise you.";
    var w8="Business Name";
    var def8="A Business name is the name a business uses to do its work.  It lets customers know who you are.";
    var w9="Business Registration";
    var def9="When you start a business you need to register your ABN, you may need to register your business name.";
    var w10="Cash flow";
    var def10="Cash Flow for a business is having enough cash saved to be able to pay your bills when they are due.";
    var w11="Characteristic";
    var def11="The characteristics of something are describing words about that thing.";
    var w12="Charges";
    var def12="A charge is something you have to pay, an expense.";
    var w13="Company";
    var def13="Is the same as a corporation. A company is a type of business that needs to be registered (either State or Federal) and has special legal status.  A company can put Pty. Ltd after it’s business name.";
    var w14="Competitor";
    var def14="A competitor is another business that is challenging you for customers.";
    var w15="Constitution";
    var def15="A constitution in business is a list of rules and principles that a company has agreed to follow.";
    var w16="Corporations Aboriginal and Torres Strait Islander Act";
    var def16="In the 1960s and 1970s, various reviews advised the Australian Government of the need for legislation to make it easier for Indigenous communities and organisations to form corporations. As a result, the ACA Act was passed, allowing Aboriginal and Torres Strait Islander groups to form corporations for any social or economic purpose.";
    var w17="Corporations Act";
    var def17="The Australian Securities and Investments Commission (ASIC) have laws that apply to corporations and these are found in the Corporations Act.";
    var w18="Cultural knowledge";
    var def18="Cultural knowledge is special information that is held by a particular cultural group, this could include technologies (e.g. special ways of using materials, making and using tools), stories, language and song, cultural rules, taboos, regulations and oral history.";
    var w19="Customer";
    var def19="The customer is someone who is buying something from a business.";
    var w20="Debt";
    var def20="Is something that you have to pay back. If you borrow 20 dollars you have a $20 debt.";
    var w21="Direct competitor";
    var def21="Is selling exactly the same thing as your business and competing for your customers.";
    var w22="Dividend";
    var def22="A dividend is money that is paid to shareholders regularly out of the company’s profits.";
    var w23="(Microsoft) Excel";
    var def23="Microsoft Excel is a computer program that lets you keep lists of numbers and also add up totals and do other sums to those numbers.";
    var w24="Fees";
    var def24="A fee is something that you have to pay, an expense.";
    var w25="Financial Management";
    var def25="Financial Management is the planning, organising, checking  and controlling of the income, expenses and Tax for a business.";
    var w26="Franchise";
    var def26="A franchise is a type of business you can buy. When you buy a franchise you set up the same type of business that has been successful somewhere else.";
    var w27="General ledger";
    var def27="A general ledger for a business is where all of the income and expenses for that business are kept in a document.";
    var w28="Goal";
    var def28="A goal is a target that you set yourself or your business.  Something that you want to achieve.";
    var w29="Growth opportunity";
    var def29="A growth opportunity is a chance for a business to get bigger.";
    var w30="GST";
    var def30="The Goods and Services Tax is paid when you buy things. Some items like food and medicine do not have the Goods and Services tax charged to them.";
    var w31="ICN";
    var def31="Indigenous Corporations Number is a special number given each indigenous corporation to identify it. No two indigenous corporations can have the same ICN.";
    var w32="Incorporate";
    var def32="Incorporate is what people do when they create a company or corporation.";
    var w33="Indirect competitor";
    var def33="An indirect competitor is selling a similar product or service to your business.  E.g. If you had a pizza shop, a fried chicken shop is an indirect competitor because it sells food and your customers might want to eat chicken instead of pizza.";
    var w34="Labour";
    var def34="Labour is all the work done by people (including you) in your business.";
    var w35="Legal name";
    var def35="Your Legal Name is the name that is on your Birth Certificate.";
    var w36="Legal protection";
    var def36="Legal protection means you are protected under the law from certain things happening.";
    var w37="Legal structure (business)";
    var def37="Legal structure is the type of business, sole trader, company, partnership.";
    var w38="Liability";
    var def38="A liability is something you are responsible for.";
    var w39="Licence";
    var def39="A license is proof that you have permission to do something.  For example, if you have a driving license you can drive a car.";
    var w40="Lodge";
    var def40="To lodge a form means to send it to where it has to go.";
    var w41="Manufacturing";
    var def41="A manufacturing business makes things.";
    var w42="Marketing budget";
    var def42="A marketing budget is the amount of money you have set aside for advertising and promotion for your business.";
    var w43="Minor criminal convictions";
    var def43="A minor criminal conviction is something small you have been in trouble over with the police.  Shop lifting is an example of a minor criminal conviction. ";
    var w44="MYOB";
    var def44="MYOB is financial management software for business.";
    var w45="Networks";
    var def45="A network for business is all of your contacts, customers and the people you know through doing business. ";
    var w46="Obligations";
    var def46="Obligations are things you are responsible for.";
    var w47="One off";
    var def47="A “one off” cost is something that only needs to be paid for once.";
    var w48="Operating budget";
    var def48="The Operating Budget is a record of the income and expenses of a business.";
    var w49="Overheads";
    var def49="Overheads are the expenses or costs in running your business, the things you have to pay for.";
    var w50="Partnership";
    var def50="A partnership is where two or more people own and run a business.";
    var w51="Permission";
    var def51="Permission is where you ask if you can do something.  If you ask and the person, group or council and they say yes, you have permission.";
    var w52="Permit";
    var def52="A permit is a special license or permission to do something";
    var w53="Personal assets";
    var def53="Personal assets are things that you own, like your car, house and furniture.";
    var w54="Personal protection";
    var def54="Being part of a company offers the shareholders some personal protection from legal and debt liabilities. This means that they have less responsibility than a Sole trader.";
    var w55="Photo identification";
    var def55="Photo Identification is a document that shows who you are and has your photo on it, like a Driver’s License, 18+ card or a passport.";
    var w56="Postal address";
    var def56="Your postal address is the address where you get your mail sent.  It might be different to the address where you live.";
    var w57="Pricing structure";
    var def57="Pricing structure is where prices for something can change depending on how much the customer orders.  The bigger the order the cheaper the price becomes.";
    var w58="Private";
    var def58="Private means not part of government.";
    var w59="Profitable";
    var def59="Profitable means that there is money left over after a business pays for all of its expenses out of the money it has made.";
    var w60="Promote";
    var def60="When you promote something you try to advertise or increase the amount of people who know about it.";
    var w61="Public liability insurance";
    var def61="Public Liability Insurance gives legal protection to the business owner against getting sued by a member of the public for things like injury or property damage. ";
    var w62="Quickbooks";
    var def62="Quickbooks is financial management software for business. ";
    var w63="Registered";
    var def63="Registered means that you have recorded your information on an official list.  You register your car to be able to drive it on the road.";
    var w64="Regulations";
    var def64="Regulations are rules or laws that control what you can and can’t do.";
    var w65="Retail";
    var def65="Retail is where things get sold in small amounts to customers.  Retail usually happens in a shop and the prices are higher.";
    var w66="Service";
    var def66="A Service business provides a service, like lawn mowing or accounting services.";
    var w67="Shareholders";
    var def67="Shareholders are people that own part of a company.";
    var w68="Sole trader";
    var def68="A sole trader is where one person owns and runs a business.";
    var w69="Start up budget";
    var def69="A Start Up Budget is the first Budget that gets done for a starting business and includes all of the costs involved in setting up the business.";
    var w70="strategy";
    var def70="A strategy in business is a plan of attack, or a plan of how to get something done.";
    var w71="system";
    var def71="A system is business is a set of detailed plans and rules for how to do something in your business.";
    var w72="Vision";
    var def72="Vision in business is being able to imagine and see something in the future.  To set up a new business you need to be able to see something new that wasn’t there before.";
    var w73="Wholesale";
    var def73="Wholesale is where things get sold in large amounts, usually for a cheaper price. The Wholesale price. A wholesaler is usually a big shed where goods are stored. Wholesale is not usually available to just anyone.";

    no, that's not a reason you would use a class file.
    anyway, your document class variables are defined on the main timeline so to reference them from any timeline you can use:
    MovieClip(root).w36;  // for example  (but it's really undesirable to have coding in more than one timeline)

  • Infotype needed  for firm booking and canceling at PV12 transaction.

    Dear All,
              I am workflow consultant.I am not well aware of infotype details for the following scenario.
              I am now involved in workflow development for SAP HCM training and event management.
              When firm booking or cancel booking is done at PV12 transaction, workflow should trigger.
              Should workflow trigger on booking or canceling it, I have to maintain infotype details in HR master tables.
              So, please state about what is the infotype for firm booking and cancel booking for which I'll be grateful.
    Thanks and regards,
    S.Suresh

    Dear all,
                  Any one one know where to check for the infotype which is getting affected when firm booking or cancel is made in PV12 transaction?
                  Please suggest for which I'll be grateful.
    Thanks and regards,
    S.Suresh

  • I started my update for ios 5.1for iPhone 4s and cancelled it have way through now it says it's downloaded but really it's not the update is still there and when I try to update it it says unable to install update : an error occurred installing iOS 5.1  ?

    I started my update for ios 5.1for iPhone 4s and cancelled it have way through now it says it's downloaded but really it's not the update is still there and when I try to update it it says unable to install update : an error occurred installing iOS 5.1  ?

    See Here... Unable to Update or Restore...
    http://support.apple.com/kb/HT1808

  • HT1918 i have recently moved from the uk to australia and cancelled my uk debit before the payment was processed for songs i bought in itunes. i have tried to edit my billing info with australian debit details but the site says 'invalid card' how can i fi

    i have recently moved from the uk to australia and cancelled my uk debit before the payment was processed for songs i bought in itunes. i have tried to edit my billing info with australian debit details but the site says 'invalid card' how can i fix this?

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • My daughter who used to have an apple account and cancelled it is still having money taken out of her account.?

    MY daughter who used to have an apple iTunes account and cancelled it is still getting money taken out of her account what do I do guys to sort this out and get her a refund.

    If she logs into her account (an account can't be cancelled or deleted, you can only stop using it) on her computer's iTunes via the Store > View Account menu option, there should be a Purchase History section with a 'see all' link to the right of it - clicking on that should then display a list of her purchases. If she no longer has iTunes installed then she might be able to see recent purchases via this page : http://reportaproblem.apple.com
    Did she have any auto-renewing subscriptions that she didn't stop ? There are instructions on this page for managing and stopping them : http://support.apple.com/kb/HT4098
    Depending upon what the charged are, she can try contacting iTunes Support and see if they will refund or credit her : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • I signed up for membership Friday November 7 and cancelled Monday, November 10. Will I receive any kind of a refund?

    I signed up for membership Friday November 7 and cancelled Monday, November 10. Will I receive any kind of a refund?

    Hi troyshari,
    You certainly will. I just processed a full refund for you. You can expect to see it in your account in the next 5-7 business days (likely sooner). Here is the transaction ID for your reference:  AD014666892
    Best,
    Sara

Maybe you are looking for