Practical Implementing Assignment Task (C1)
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Practical Implementing Assignment Task (C1)
Task
Stephen has a lot of flowers (N) in his garden. He has a list about the flowers like name and count.
Write a C++ application to answer the following questions. You should pay attention to the regular application of pattern of algorithm! (2-2 points) Use functions and read data from console with checking them!
The questions:
a) Select those flowers that he has more than 40!
b) His dog ate all of tulip. How many percent of flowers remained?
Specification
Input: |
N:Integer, flowers:Array[1..N:(name x count)], name:String, count: Integer |
Outputa : |
cnt: Integer; names:Array[1..cnt:String] |
Outputb : |
remainedPercent:Decimal number |
Precondition: |
- |
Postconditiona : |
cnt = ∑N i =1 1 and ∀i(1 ≤ i ≤ cnt)∃j(1 ≤ j ≤ N): namesi = |
flowersi .count>40
flowersj. name ∧ flowersj . count > 40 and isSet(names)
Postconditionb : remainedPercent = 100 * ∑N i =1 flowersi . count /
flowersi.name≠tulip
∑1 flowersi . count
Algorithm
NSDa
NSDb
2022-11-22