Question
IN JAVA PLEASE DON'T USE METHODS, THANK YOU!! Write a program to simulate a self-service bike share station. The bike share provides the following: The
IN JAVA PLEASE DON'T USE METHODS, THANK YOU!!
Write a program to simulate a self-service bike share station. The bike share provides the following: The bike share station simulation starts with 9 bikes. Rental options: 1-Hour Rental, 2-Hour Rental, 6-Hour Rental, and Returning a Bike Limits each rental transaction to a maximum of 4 bikes as long as 4 bikes are available in station Displays the unlock codes for each rental bike Displays a receipt for each rental Has a shutdown mode (shutting the bike station down stops the simulation) Specifications 1. To simulate the bike share station, the code must do 2 tasks: o provide a customer mode and o provide a way to shut down the bike station Task 1: provide a customer mode o Create a loop that waits for a customer This is the main loop and it iterates until the bike share is shut down See task 2 for details on shut down mode o Display a menu that Shows the number of bikes available Shows rental options:
1-hour Pass set price to $1.50 2-hour Pass set price to $2.50 6-hour Pass set price to $4.00 Return Bike o Prompt customer for: The rental option The number of bikes to rent - max allowed is 4 For each prompt, the code must validate the user input and allow reentry before moving forward. This means, for each prompt, the code must loop until the user input is valid. See Must Do and Tips and output below for an example. o If option is 1-Hour Pass, 2-Hour Pass, or 6-Hour pass display a receipt that contains: Rental option selected (1, 2, or 6 hours) Number of bikes rented Total rental cost Unique unlock code for each rental bike Create a for loop that iterates based on the number of bikes. Generate unique random numbers to represent unlock codes. Unlock code must be a 5-digit number Unlock code for bike# 1: 21260 Unlock code for bike# 2: 51043 o If option is Return Bike, display a bike was successfully returned statement. Note: The station must have room, see Must-Do section for information on full station Only one bike at a time can be returned. o If option is shut down the station Code must exist the main loop (customer mode) and display grand totals o The main loop for the customer mode could look something like the following: boolean stationInService = true; while (stationInService) { // Inside loop you will change stationInService to false // when 999 is entered } Task 2: provide a way to shut down the station and print a report with grand totals for station. o Essentially, we need a way to stop the main customer loop and end the program. o Well call this shutting down the bike station. o Perform these steps: At the main menu, when asked for the rental option, an employee enters the shutdown code 999. If the shutdown code 999 is entered, then the while loop (customer mode) must end. This means, the code will exit the loop and create a report showing: Total number of bikes rented for all customers
Total sales for all customers Must-Do and Tips Must Do: General Use correct data types and constants Constants must be used for each different rental price. For example: final double ONE_HOUR_PRICE = 1.50; Must Do: While loops and For loops are required Main code structure o Must use a while loop that waits for customer input. o Must use a for loop to create and display the unlock code for each bike being rented. User input validation o Must use additional while loops to validate user input. o When there is a user input error, ask user to reenter before doing any more processing. o The next bullet below show the proper output with errors. Note the menu is not displayed again. Instead the code uses a loop at the location where the error occurs to ask for reentry of user input and continues to loop until a valid input is entered. DO NOT break out of any loop with break or continue statements. o Instead, write proper loops, otherwise you will lose points. o While loop must iterate until the loop condition is false. o For loop must iterate for the specified number of iterations. Must Do: Handle invalid user input The code must handle user validation for the menu selection and number of bikes to rent. If invalid input is entered, repeat the question for the menu selection or number of bikes until a valid value is entered. Select rental option 1, 2, 3, or 4: 0 Invalid entry. Enter 1, 2, 3, or 4: 5 Invalid entry. Enter 1, 2, 3, or 4: 1 How many bikes do you want to rent? Limit is 4: 0 Invalid entry. Enter number between 1 and 4: 4 Invalid entry. Enter number between 1 and 4: 1 Must Do: Dealing with a full or empty bike station The bike share station simulation starts with 9 bikes. Code must keep track of the number of bikes currently available. Code must handle if station is full and there is no room to return a bike Code must handle a request where the station does not have enough bikes:
o Full station: code must indicate there are no empty docks. For example, when first running the code, the station is full so if the user tries to return a bike (option 4 in menu), the code needs to indicate this fact. Select menu option 1, 2, 3, or 4: 4 Station is full, please use a different station. o Requesting more bikes than are available: code must indicate there are not enough bikes available. In this example, only 2 bikes are available and the user wants to rent 3 bikes for 2-hours: Select rental option 1, 2, 3, or 4: 2 How many bikes do you want to rent? The limit is 4: 3 There are only 2 bikes available. Request cannot be fulfilled. Please use a different station. Tip: Write code incrementally! Focus your thinking on one piece at a time, write that code, then go to next piece. Write the skeleton while loop that displays the menu and reads the number of bikes desired. Next add code to determine if in customer mode or shut down mode. Test that the loop ends when shut down code (999) is entered. Keep adding in one new piece of functionality and get it working before adding in anything else. Focus your thinking on one piece at a time, write that code, then go to next piece. Tip: View this website to learn about bike share stations: https://www.capitalbikeshare.com/ Output Your output should look similar to the following: ************************************************ Welcome to Bike Share 9 bikes are available Note indication of # bikes ************************************************ Rental Options Fee ------------------------------------------------- 1) 1-Hour Pass $1.50 2) 2-Hour Pass $2.50 3) 6-Hour Pass $4.00 4) Return Bike ------------------------------------------------- Values entered by user Select rental option 1, 2, 3, or 4: 1 How many bikes do you want to rent? The limit is 4: 4 ------------------------------------- -------------- Receipt -------------- ------------------------------------- 1-hour rental for 4 bikes Unlock code for bike# 1: 60725 Unlock code for bike# 2: 94169 Unlock code for bike# 3: 43749 Unlock code for bike# 4: 71823 Rental Cost: $6.00 Thank you for your business! ------------------------------------- ************************************************ Welcome To Bike Share
Note that there are now only 5 bikes are available
5 bikes available. ************************************************ Rental Options Fee ------------------------------------------------- 1) 1-Hour Pass $1.50 2) 2-Hour Pass $2.50 3) 6-Hour Pass $4.00 4) Return Bike ------------------------------------------------- Select menu option 1, 2, 3, or 4: 0 Example of handling Invalid entry. Enter 1, 2, 3, or 4: 5 invalid menu option Invalid entry. Enter 1, 2, 3, or 4: 2 How many bikes do you want to rent? The limit is 4: 0 And invalid # bikes Invalid entry. Enter number between 1 and 5: 5
Invalid entry. Enter number between 1 and 5: 3 ------------------------------------- -------------- Receipt -------------- ------------------------------------- 2-hour rental for 3 bikes Unlock code for bike# 1: 77256 Unlock code for bike# 2: 60947 Unlock code for bike# 3: 33314 Rental Cost: $7.50 Thank you for your business! ------------------------------------- ************************************************ Welcome to Bike Share Station is down to 2 bikes 2 bikes are available ************************************************ Rental Options Fee ------------------------------------------------- 1) 1-Hour Pass $1.50 2) 2-Hour Pass $2.50 3) 6-Hour Pass $4.00 4) Return Bike ------------------------------------------------- Select rental option 1, 2, 3, or 4: 1 bikes available can How many bikes do you want to rent? The limit is 4: 3 not fulfil request There are only 2 bikes available. Request cannot be fulfilled. Please use a different station. ************************************************
Welcome To Bike Share 2 bikes are available ************************************************ Rental Options Fee ------------------------------------------------- 1) 1-Hour Pass $1.50 2) 2-Hour Pass $2.50 3) 6-Hour Pass $4.00 4) Return Bike ------------------------------------------------- Successfully returning a bike Select menu option 1, 2, 3, or 4: 4 (Now station has 3 bikes) Bike was successfully returned ************************************************ Welcome To Bike Share 3 bikes are available ************************************************ Rental Options Fee ------------------------------------------------- 1) 1-Hour Pass $1.50 2) 2-Hour Pass $2.50 3) 6-Hour Pass $4.00 4) Return Bike ------------------------------------------------- Example showing station shut down using 999 for menu option Select menu option 1, 2, 3, or 4: 999 Bike Station at Main Hall was successfully shut down Total Bikes Rented = 7 total number of bikes rented
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started