// Variables Numeric shoeID // ID# (1000 to 9999) Numeric shoeSize // shoe size
ID: 3556767 • Letter: #
Question
// Variables
Numeric shoeID // ID# (1000 to 9999)
Numeric shoeSize // shoe size
String firstName // first name of renter
String lastName // last name of renter
String rentalDate // rent date (MM/DD/YYYY)
String rentalTime // rent time (HH:MM, 24-hr)
Numeric numGames // number of games bowled
Numeric rentalCost // rental cost ($2 per game)
// Constructor method for shoe rental
Constructor Method for shoe rental
Display "Enter the shoe ID number: "
Input shoeID
Display "Enter the shoe size:"
Input shoeSize
Display "Enter renter's first name:"
Input firstName
Display "Enter renter's last name:"
Input lastName
Display "Enter date (MM/DD/YYYY):"
Input rentalDate
Display "Enter time (HH:MM):"
Input rentalTime
Display "How many games is renter bowling? "
Input numGames
rentalCost = computeRentalCost(numGames)
End Method
// Method to compute rental cost
Numeric computeRentalCost(Numeric games)
Constant Numeric COST_PER_GAME = 2
Declare Numeric cost
cost = games * COST_PER_GAME
Return cost
End Method
// Method to display info
displayInfo()
Display "Renter's name:" + firstName + " " + lastName
Display "Shoe ID:" + shoeID
Display "Shoe size: " + shoeSize
Display "Rental date: " + rentalDate
Display "Number of games bowled: " + numGames
Display "Cost of rental: " + rentalCost
End Mehod
End Method
// Welcome the user
Display "Welcome to Lanes Galore Shoe Rentals"
// Rent a pair of shoes to a customer
Shoe Rental nextCustomer = new ShoeRental()
nextCustomer.displayInfo()
// Thank the user
Display "Thank you!"
Stop
Explanation / Answer
i am giving you a basic idea of how to declare and write a function...hope you got it....ask me if you need help to complete i can do this...
var shoeID;
var shoeSize;
var firstName;
var lastName;
var rentalDate;
var rentalTime;
var numGames;
var rentalCost;
function ShoeRental(){
shoeID = prompt(Enter the shoe ID number:);
shoeSize = prompt(Enter the shoe size:);
firstName = prompt(Enter renter's first name:);
lastName = prompt(Enter renter's last name:);
rentalDate = prompt(Enter date (MM/DD/YYYY):);
rentalTime = prompt(Enter time (HH:MM):);
numGames = prompt(How many games is renter bowling? );
rentalCost = computeRentalCost(numGames)
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.