Answer to Question #42550 in C++ for zoher

Question #42550
The assignment is accompanied by a solution to the rst assignment, pro-
gram
tinmail.v1.0.cpp
. This program is slightly adapted to t with this
second assignment better. You can build your new program either on program
tinmail.v1.0.cpp
, or on the program that you wrote yourself for the rst
assignment. That choice is up to you.
This assignment is also accompanied by executable
marsmail02.exe
, which
solves the second programming task for planet Mars.
3.1 Programming Task 1 (30 marks)
For this assignment you will have to write a program that implements the fol-
lowing pseudo code:
1. Ask for strength of the sea breeze (Beaufort number) and validate it.
2. If the Beaufort number is larger than 6, tell that it is too windy and quit
3. Otherwise do the following
(a) Ask for the launch angle
(b) Select a random angle from the range [
1
;
+ 1], where
is the
angle provided by the user.
The initial speed
etc are dened on
page 4.
(c) Compute the initial speed of the container in x and y-direction, using
the selected angle.
Look up the
ranges for wind
and waves in
Table 1.
(d) Select a random wind speed from the range that corresponds to the
Beaufort number provided by the user.
(e) Select a random wave height from the range that corresponds to the
Beaufort number provided by the user.
See Section 2.3
for how to select
random values.
(f) Repeat the following, as long a the y-position is positive or the speed
in y-direction is positive
i. Compute the new positions
How to compute
new position
and speed? See
the description
on page 6 in
Subsection 2.4.
ii. Compute the new speeds
(g) Print the x-position where the projectile will land.
You will have to write a function for each of the following steps in the pseudo
code above:
Ask for strength of the sea breeze (Beaufort number) and validate it.
Ask for the launch angle and validate it.
Select a random wind speed from the range that corresponds to the Beau-
fort number provided by the userSelect a random wave height from the range that corresponds to the Beau-
fort number provided by the user.
The text in
boldface
is
important.
You will have to use these functions in your main function.
Each of
these functions may use other functions, in particular the function
random
steps
.
Please submit the C++ code of your solution on Moodle.
3.2 Programming Task 2 (30 marks)
For this task you will have to extend your program for Subsection 3.1. It
should compute 100 trajectories, store the data in an array of size 100, and
then compute the average, and the number of times a letter landed within a 1
m
distance from the average.
The program should implement the following pseudo code:
Ask for strength of the sea breeze (Beaufort number) and validate it.
If the Beaufort number is larger than 6, tell that it is too windy and quit
Otherwise do the following
{
Ask for the launch angle
{
Repeat the following 100 times
Select a random angle from the range [
1
;
+ 1], where
is
the angle provided by the user.
Compute the initial speed of the container in x and y-direction,
using the selected angle.
Select a random wind speed from the range that corresponds to
the Beaufort number provided by the user.
Select a random wave height from the range that corresponds to
the Beaufort number provided by the user.
Repeat the following, as long a the y-position is positive or the
speed in y-direction is positive
Compute the new positions
Compute the new speeds
Store the x-position where the projectile will land in an array.
{
Compute the average of stored distances.
{
Compute the number of times that a letter lands within 1
m
distance
from the average.
{
Print the average, and the percentage of times that the letter landed
within 1
m
distance.
In addition to the functions mentioned for the programming task 3.1, your
program should include functions for:
Compute the average of stored distances.
Compute the number of times that a letter lands within 1
m
distance from
the average.
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS