Description
PS2-1 Sine Wave on the Console Window[ps2-1.cpp] (30 pts)
Write a function called:
void Hash(int x);
which prints x hash marks (#) and a line break (\n or std::endl).
In main function, run a loop on a double-precision floating point from zero to 100 with 0.1 increment.
Inside the loop, call Hash function to draw (40+sin(a)*40) hash marks.
Include appropriate header files. You can choose C standard library or C++ Standard Template Library.
The program will render a sine wave on the console window.
Make sure your program can be compiled with no error in one of the compiler servers. Don’t wait until
the last minute. Compiler servers may get very busy minutes before the submission deadline!
Sample Output (Expand the window so that it at least prints 80 characters in a row).
PS2-2 Digital Flashcards of Multiplication [ps2-2.cpp] (70 points)
In this problem, you will write a C++ code that serves as a learning tool for elementary multiplication
from 1×1 to 12×12. Your C++ code should be a console application and roughly mimics the functionality
of a conventional paper flashcard, shown in the figure below.
A flashcard is any of a set of cards bearing information, as words or numbers, on either or both sides,
used in classroom drills or in private study. Flashcards can bear vocabulary, historical dates, formulas or
any subject matter that can be learned via a question and answer format. Flashcards are widely used as
a learning drill to aid memorization by way of spaced repetition.
Your C++ console flash card should:
First ask the user how many flash cards to work on. The number needs to be between 1 and 144.
If the user requests less than 1 or greater than 144 flash cards, show a message (eg. “The
number of cards must be between 1 and 144.”) and prompt the user to re-enter a different
number.
Show questions one by one on the console window and prompt the user to type the answer. If
the user types a wrong answer, tell the user that the answer is wrong and show the correct
answer then move on to the next card. If the answer is correct, move on to the next card.
When all the flash cards are answered, display a feedback comment that includes:
– The number of problems,
– Time required to complete the problems in the number of seconds
– The number of correct answers and percent that the user answered correctly.
For example,
You answered 25 problems in 80 seconds.
You answered 20 problems correctly (80%).
The time for completion does not have to be sub-second accurate. It can have plus-minus 1
second error. Make sure you measure real time, not CPU time in any environment.
Problems should be selected and presented randomly, but no same question should appear
more than once. Make sure to use srand so that the order of the card appearance changes time
to time.
Write the C++ program (named ps2-2.cpp). For full credit:
Make shuffling a separate function (and use it).
Also make a separate function for swapping two integers and use it from the shuffling function.
The C++ source code must be included in the Zip file that you submit to the Canvas.
Make sure your program can be compiled with no error in one of the compiler servers. Don’t wait until
the last minute. Compiler servers may get very busy minutes before the submission deadline!
Hint: You really need one integer per card.
#0
1×1=
#1
1×2=
#2
1×3=
#3
1×4=
#4
1×5=
#5
1×6=
#6
1×7=
#7
1×8=
#8
1×9=
#9
1×10=
#10
1×11=
#11
1×12=
#12
2×1=
#13
2×2=
#14
2×3=
#15
2×4=
#16
2×5=
#17
2×6=
#18
2×7=
#19
2×8=
#20
2×9=
#21
2×10=
#22
2×11=
#23
2×12=
#24
3×1=
#25
3×2=
#26
3×3=
#27
3×4=
#28
3×5=
#29
3×6=
#30
3×7=
#31
3×8=
#32
3×9=
#33
3×10=
#34
3×11=
#35
3×12=
#36
4×1=
#37
4×2=
#38
4×3=
#39
4×4=
#40
4×5=
#41
4×6=
#42
4×7=
#43
4×8=
#44
4×9=
#45
4×10=
#46
4×11=
#47
4×12=
#48
5×1=
#49
5×2=
#50
5×3=
#51
5×4=
#52
5×5=
#53
5×6=
#54
5×7=
#55
5×8=
#56
5×9=
#57
5×10=
#58
5×11=
#59
5×12=
#60
6×1=
#61
6×2=
#62
6×3=
#63
6×4=
#64
6×5=
#65
6×6=
#66
6×7=
#67
6×8=
#68
6×9=
#69
6×10=
#70
6×11=
#71
6×12=
#72
7×1=
#73
7×2=
#74
7×3=
#75
7×4=
#76
7×5=
#77
7×6=
#78
7×7=
#79
7×8=
#80
7×9=
#81
7×10=
#82
7×11=
#83
7×12=
#84
8×1=
#85
8×2=
#86
8×3=
#87
8×4=
#88
8×5=
#89
8×6=
#90
8×7=
#91
8×8=
#92
8×9=
#93
8×10=
#94
8×11=
#95
8×12=
#96
9×1=
#97
9×2=
#98
9×3=
#99
9×4=
#100
9×5=
#101
9×6=
#102
9×7=
#103
9×8=
#104
9×9=
#105
9×10=
#106
9×11=
#107
9×12=
#108
10×1=
#109
10×2=
#110
10×3=
#111
10×4=
#112
10×5=
#113
10×6=
#114
10×7=
#115
10×8=
#116
10×9=
#117
10×10=
#118
10×11=
#119
10×12=
#120
11×1=
#121
11×2=
#122
11×3=
#123
11×4=
#124
11×5=
#125
11×6=
#126
11×7=
#127
11×8=
#128
11×9=
#129
11×10=
#130
11×11=
#131
11×12=
#132
12×1=
#133
12×2=
#134
12×3=
#135
12×4=
#136
12×5=
#137
12×6=
#138
12×7=
#139
12×8=
#140
12×9=
#141
12×10=
#142
12×11=
#143
12×12=
Exercise: You do not submit anything for the exercise, and will not be penalized for not working on the
exercise. Just for your practice.
Re-write Shuffling algorithm using Range-Based For loop.

