second task
This commit is contained in:
parent
37ee02b039
commit
c8e5b36209
1 changed files with 29 additions and 4 deletions
33
src/main.cpp
33
src/main.cpp
|
@ -1,5 +1,6 @@
|
|||
#include <iostream> // for std::cout
|
||||
#include "io.h"
|
||||
#include <cmath>
|
||||
|
||||
// Definition of function main()
|
||||
double get_user_double()
|
||||
|
@ -38,15 +39,39 @@ void print_result(double a, double b, char c)
|
|||
}
|
||||
std::cout << a << ' ' << c << ' ' << b << " is " << result;
|
||||
}
|
||||
void task1()
|
||||
{
|
||||
double a{get_user_double()};
|
||||
double b{get_user_double()};
|
||||
char c{get_user_operator()};
|
||||
print_result(a, b, c);
|
||||
}
|
||||
|
||||
long get_user_tower_height()
|
||||
{
|
||||
std::cout << "Enter the height of the tower in meters: ";
|
||||
long x{};
|
||||
std::cin >> x;
|
||||
return x;
|
||||
}
|
||||
void task2()
|
||||
{
|
||||
long tower_height{get_user_tower_height()};
|
||||
for (size_t i = 0; i < 6; i++)
|
||||
{
|
||||
double result{static_cast<double>(tower_height) - 9.8 * pow(static_cast<double>(i), 2) / 2};
|
||||
if (result <= 0.0)
|
||||
std::cout << "At " << i << " seconds, the ball is on the ground\n";
|
||||
else
|
||||
std::cout << "At " << i << " seconds, the ball is at height: " << result << " meters\n";
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
// add_two_numbers();
|
||||
// convert_char_to_ascii();
|
||||
// print_type_size_bytes();
|
||||
double a{get_user_double()};
|
||||
double b{get_user_double()};
|
||||
char c{get_user_operator()};
|
||||
print_result(a, b, c);
|
||||
// task1();
|
||||
task2();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue