Question: Exercise 2 (30%) Please write a C++ program to read an integer x and output f(x) rounded to three decimal places, where the f(x) is

Exercise 2 (30%) Please write a C++ program to read an integer x and output f(x) rounded to three decimal places, where the f(x) is defined as follows: 2x2 +5, f(x) = X-2 4 if x is odd if x is even 1 Some sample runs are shown as follows (underlined bold characters in blue are user input): Sample Run 1 Input x: 3 f(x) = 4.796 Sample Run 2 Input x: -5 f(x) = 7.416 Sample Run 3 Input x: 12 f(x) = 2.500 Please name your C++ source file as Lab1Ex2.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
