CMSC140 Classwork 6 - Updated103123
CMSC140 Classwork 6 - Updated103123
Classwork Requirements:
This classwork consists of two different parts. For each part you need to submit a separate cpp
and word/pdf document.
Part 1:
Develop a program that allows the user to choose addition or subtraction operations on two
whole numbers entered from the keyboard.
Input Process Output
1. Choice of operation Validate the choice, Result of operation
2. First number If choose to perform
3. Second number operation, add two numbers;
otherwise, subtract two
numbers
Note:
Break the problem into smaller piece(s).
Your functions’ signature should match the given flowcharts in the file attachment.
Main
returns
whether the return return
return
choice is (result) (result)
(choice)
valid or not
addition
(num1,
You must declare function prototypes above main function and define the functions
below main function.
Example Output:
Submit:
showMenu function:
takePurchase
(price) takePurchase function:
Prompt for choice
1. Prompts the user for quantity
2. Reads the quantity
3. Returns the purchase price (price *
quantity)
Sample Outputs:
Prompt for quantity
Save price
displayInfo
Return Price of choice Save quantity (purchase, payment)
General
Save payment Requirements:
amount
Name your source file FirstInitialLastName_CW_[classwork #].cpp
Calculate change (payment -total
Include the following in your code in C++ source .cpp: purchase)
o Program Header: All programming projects’ source code need to have one block
Return (payment)
comment at the top of the program containing the course name, CRN, the project
number, your name, project description, and the due date.
o Provide any additional comments as necessary to clarify the program.
Display calculated values
Following is a template of the required program header:
/*
* Class: displayInfo function: CMSC140 CRN
* Instructor:
* 1. It calculates tax by multiplying Project<number>
* purchase by 6% Description: (Give a brief
description 2. It calculates total purchase cost; for Project)
* Due Date: purchase+ Calculated tax
* I pledge 3. It calculates change amount due that I have completed the
programming to the customer; payment -total assignment independently.
I have not purchase copied the code from a
student or 4. It displays tax, total purchase any source.
I have not cost and change due. given my code to any
student.
Print your Name here: __________
*/
takePayment function:
The classwork part 1 with correct name and requirement has been 30
submitted.
Word document part 1 with correct name and requirement has been 20
submitted.
The classwork part 2 with correct name and requirement has been 30
submitted.
Word document part 2 with correct name and requirement has been 20
submitted.
100
Classwork Specific Points Deducted:
Part 1:
Section (i) has not used while loop -10
Section (ii) has not used do-while loop -10
Other sections have not used nested for loop -10
Part 2:
Full name is not read and stored using one read statement. -5
Full name is not read and stored. -5
Phone number is not read and stored. -5
Street address is not read and stored. -5
City is not read and stored. -5
State is not read and stored. -5
Zip code is not read and stored. -5
File is not saved correctly -5
Data is not displayed correctly from file to the console. -5
Wrong file name has been used -5
General Points Deducted: