SENG1000 - C/C++ Programming Using Arrays And C++ Strings Assignment

Download Solution Order New Solution

Assignment Task

General Course Objectives Addressed In This Assignment

  • Declare and use arrays, with initial
  • Pass arrays as
  • Use the C++ string
  • Use streams for simple standard input and
  • Use appropriate scope and
  • Use arithmetic
  • Use if-else
  • Use a
  • Use pre-existing
  • Split your code into modular
  • Make appropriate design
  • Follow stated requirements

ARRAY DECLARATION

  • Declare an array of The name of the constant must adhere to the SET Coding Standards. It must be a const array (i.e. const should precede the data type).
  • This array must be declared in main().
  • This array must have the following values (in order):
    • 127.50
    • 128.25
    • 130.50
    • 150
    • 150
    • 162.50
  • Each element of the array represents the room rate on a particular night, starting on Sunday. So, the rate for Sunday is 127.50, the rate for Monday is 128.25, etc.

The Attendees

  • Up to four people are renting hotel rooms in order to attend a
  • The meeting is on However, each person has other tasks that they can do once they are in town so they might arrive earlier or leave later.
    • The week starts on Sunday (earliest check in) and ends on Saturday (latest check out).
    • In the case that any of the following constraints are violated, display an error message and skip this person.
      • They must check in Thursday at the
      • They must check out Thursday at the
      • They cannot check in and check out on the same day (i.e. they need to stay in the hotel for at least one day).
    • You must have a loop in main() that prompts the user for each of the The user must enter (on separate lines):
      • the person's name (which could have multiple parts; e.g. "Fred Flintstone")
        • if the name is empty (i.e. ""), display an error message and skip this person
      • the day in which they are check-ing in to the hotel
        • all days are strings
        • "sun" represents Sunday, which is the first day in which they can check into the hotel. The other day abbreviations are "mon", "tue", "wed", "thu", "fri", "sat", accordingly.
      • the day in which they are check-ing out of the hotel (the day input is similar to above; Saturday is the last day in which they can check out)
  • All prompts for user input should not move the cursor to a new This would be a more natural user interface, in which the input is immediately to the right of the prompt.
  • For each person, display their name and their total room Then display a blank line. This is the only time when there should be a blank line in the output.
  • At the end, display the total costs for the entire

Converting Days To Numbers

  • In the array containing the room rates, the first value corresponds with the rate for Sunday. Each subsequent value corresponds with the next day of the week.
  • You must create a function called dayToIndex(). It converts from the user input to a useful array index. It is called from main().
    • It must take exactly one parameter: a string indicating what day was entered by the user.
    • It must return an int indicating the day that was entered (0 represents Sunday, 1 is Monday, etc. to 6 being Saturday) or, in the case of the user not entering a valid day string, -1 indicating an error.
  • The -1 error value must be represented by a global It must go before any function definitions in your code. The constant's name must adhere to the SET Coding Standards.
  • dayToIndex() must do no
  • The comparison is case-sensitive (e.g. "mon" represents Monday but "Mon" is an error). This is intended to make it easier for you.

Calculating Room Cost

  • In order to calculate the cost of the room for a person, you must create a function called calculateCostOfRoom(). It is called from main().
    • It must take exactly these parameters, in order:
      • the array of room rates
      • the day of check-in, as an index into the array
      • the day of check-out, as an index into the array
    • It must return the total cost for the room, as a
    • It must do no
    • There is no need for error-check-ing in this

Error Handling

  • There are five errors that you need to handle in this program:
    • Missing name
    • Invalid check-in day
    • Invalid check-out day
    • Invalid length of stay
    • Missing the meeting
  • All output for the error messages must be done in main().
  • Do your error check-ing as soon as you have the data to What that implies is the following:
    • if they are missing a name, display the error message and don't get the check-in or check-out days or display any cost
    • if the check-in day is invalid, display the error message and don't get the check- out day or display any cost
  • Any of the five errors result in skipping the person (but do not quit the program).
    • g. if two people have errors associated with them, only the other two people with valid data are attending the meeting

This SENG1000 - IT Computer Science has been solved by our PhD Experts at My Uni Paper.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.