Comp 218/EC 面向对象编程

Concordia University
Comp 218/EC – Winter 2021
Fundamentals of Object Oriented Programming
Assignment 2
__
Deadline: By 11:59pm Friday March 12th , 2021.
Evaluation: 2.5 % of your final grade
Late Submission: Late assignments will be discounted by 25%. Late assignments are accepted up to 5
days late (grace period) and weekends count.
Teams: The assignment is to be done individually.
Purpose: The purpose of this assignment is to have you experience the basic steps involved in
writing a complete C++ program (from algorithm development to coding) and to
practice with string data type variables, selection statements and the while
repetition statement.
General Guidelines When Writing Programs:
Same as for assignment #1 – Refer to assignment #1 handout for details.
RECOMMENDATION for this Assignment:
Take the time to write out an algorithm for these problems to help clarify the logic BEFORE you start
programming. (No need to hand in the algorithm.)
Question #1: Speed System Program (6 pts)
In this question, you will write a program that determines the penalty of a driver who is speeding on
highway with the speed limit of 100km/h based on Ontario Courts.
Your program should follow the following rules:
• Prompt the user to enter name, id and score and validates the information.
• The student name should be entered as “LastName, FirstName” (separated by comma).
Please note the whole name should be saved in one string.
• The driver ID must have 7 digits.
• The driver’s SPEED must greater than 0.
• If the user enter correct information, your program should display the fine based on the
speed. When the fine is displayed, the output should be
“FirstName LastName got SPEED. Based on the speed system, FirstName (ID) will pay X.”
Please note the calculation of X is based on the following rules:

  • A $2.50/km speeding fine for 1-19km/h over the speed limit.
  • A $3.75/km speeding fine for 20-29km/h over the speed limit.
  • A $6.00/km speeding fine for 30-49km/h over the speed limit.
  • 50+ km/h over the speed limit comes with a court decided fine.
    • Your program should be able to ask user for new input of driver’s information for penalty
    until get the input Yes from the user.
    • Display welcome & closing messages.
    The following are sample screen shots to illustrate the expected behavior of your program. Your
    Comp 218/Winter 2021 Page 2 of 7 Assignment #2
    program must display the same information with the same format.
    User input at the keyboard is marked with a red circle.
    Figure 1 Sample output of Question#1
    Comp 218/Winter 2021 Page 3 of 7 Assignment #2
    Figure 2 Sample output of Question#1
    Questions #2: Online Order Program (8 pts).
    In this question, you will write a program to help the customer order food online and calculate the
    total price.
    Your program should follow the following rules:
    • Prompt the user to enter the choice based on the menu and validates the information
    • The choice should be an integer number displayed on menu from 1 to 6.
    • A price to calculate the total expense of the user.
    • Please find the menu and price in the following table.
    Menu Price without Meat Price with beef Price with pork
  • Hamburger $7.5 $25.5 $17.5
  • Pizza $7.5 $25.5 $17.5
  • Noodle $7.5 $25.5 $17.5
  • Salad $7.5 $25.5 $17.5
  • Sandwich $7.5 $25.5 $17.5
  • Exit
    Comp 218/Winter 2021 Page 4 of 7 Assignment #2
    • Your program should be able to ask user’s new choice if the user enters Yes for more food.
    • If the total price is less than $50, the customer needs to pay $5 for delivery.
    • Your program should ask the amount of tips that the customer would like to pay.
    • Display welcome/closing messages.
    The following are sample screen shots to illustrate the expected behavior of your program. Your
    program must display the same information with the same format.
    User input at the keyboard is marked with a red circle.
    Figure 3 Sample output of Question#2
    Comp 218/Winter 2021 Page 5 of 7 Assignment #2
    Figure 4 Sample output of Question#2
    Comp 218/Winter 2021 Page 6 of 7 Assignment #2
    Figure 5 Sample output of Question#2
    Comp 218/Winter 2021 Page 7 of 7 Assignment #2
    Submitting Assignment 2
  • Zip together the source codes (.cpp files only) for questions 1 and 2.
  • Naming convention for zip file:
    Create one zip file, containing all source files for your assignment using the following naming
    convention:
    The zip file should be called a#_studentID, where # is the number of the assignment studentID is
    your student ID number. For example, for this 2nd assignment, student 123456 would submit a
    zip file named a2_123456.zip
  • Submit only ONE version of an assignment. If more than one version is submitted the first one
    will be graded and all others will be disregarded.
    Note:
  • Late assignments will be discounted by 25%. Late assignments are accepted up to five days late (
    grace period) and weekends count.
  • Assignments not submitted in requested format may not be graded.
  • Uploading incorrect files will result in a grade of 0.
    Evaluation Criteria for Assignment 2 (20 points)
    For Assignment 2 - 6 pts.
    Comments - description of variables/ description of the steps in code/
    purpose of program
  • pts.
    Choice of variable names 1 pt.
    Indentation and readability of program 1 pt.
    Welcome and closing message 1 pt.
    Clear prompts to user & clear messages with output results 1 pt.
    Question 1 – 6 pts.
    Prompt user & read data 1 pt.
    Determine the correctness of user’s information 2 pts.
    Determine the penalty fine result 1 pt.
    Display results 1 pt.
    Question 2 – 8 pts.
    Ask for & read input data 1 pt.
    Check the valid input 1 pt.
    Determine the food type on menu and more food option 3 pts.
    Determine the delivery fee and tips 2 pts.
    Display the result 1 pt.

你可能感兴趣的:(c++)