Objective:
- User selects value from Camp A drop-down list that generated from SQL.
- Each value in Camp A needs to check in the coding and determine Camp B result.
- Camp A require at least $50. Camp B require at least $200.
- User can obtain 1 point for each $50 in Camp A. User can obtain only 1 ticket after meet the requirement in Camp B.
- Each item can be used for 1 Camp only.
Data retrieved from MySQL:
Item | Name | Price($)
----- ------------ --------
1 | Adidas | 180.00
2 | Nike Run | 70.00
3 | Puma | 15.00
4 | Nike Women | 20.00
5 | NB | 5.00
From the data shown above, the Camp A drop-down list shows maximum 5 points and Camp B shows 1 ticket. But the message box has to check in back-end whether both Camps are meet requirement.
Example A:
- User selects 5 points in Camp A, user is not allowed to select an ticket from Camp B.
- Explanation: Item 1 ($180) + Item 2 ($70) = $250. $250 divided by $50, user obtains 5, which is 5 points shown in drop-down list. Total of the remaining items are not meet $200 for Camp B. Thus message box will warn user either select Camp A or Camp B, cannot select both.
Example B:
- User selects 4 points in Camp A, user is not allowed to select an ticket from Camp B.
- Explanation: Item 1 ($180) + Item 4 ($20) = $200. $200 divided by $50, user obtains 4, which is 4 points shown in drop-down list. Total of the remaining items are not meet $200 for Camp B. Thus message box will again warn user either select Camp A or Camp B, cannot select both.
Example C:
- User selects 1 points in Camp A, user is able to select an ticket from Camp B.
- Explanation (i): Item 2 ($70) + Item 4 ($20) = $90. $90 divided by $50, user obtains 1, which is 1 point shown in drop-down list. Total of the remaining items are $200 = $180 + $15 + $5. Thus this time the message box will not prompt warning but allow user select both Camp A or Camp B at same time.
How to use for-loop of while and check the value passing from drop-down list in if-statement.
Aucun commentaire:
Enregistrer un commentaire