C Practical Questions - 095504
C Practical Questions - 095504
Please make sure that you write the string describing what input the
user should provide and the output statements exactly as shown in the
screen shots. In particular, make sure that these strings includes all
necessary white space, e.g., blanks. Due to how the tests are
performed, you will receive 0 points if there is a mismatch.
Enter a character: A
The integer equivalent of A is 65
Enter a character: 1
The integer equivalent of 1 is 49
Enter a character: 0
The integer equivalent of 0 is 48
Enter a character: #
The integer equivalent of # is 35
Enter a character: a
Please make sure that you write the string describing what input the
user should provide and the output statements exactly as shown in the
screen shots. In particular, make sure that these strings includes all
necessary white space, e.g., blanks. Due to how the tests are
performed, you will receive 0 points if there is a mismatch.
Please make sure that you write the string describing what input the
user should provide and the output statements exactly as shown in the
screen shots. In particular, make sure that these strings includes all
necessary white space, e.g., blanks. Due to how the tests are
performed, you will receive 0 points if there is a mismatch.
The following cout will be helpful:
Problem Set 10
Write a function to calculate the rate of inflation for the past year. The
function receives the current price of some item and its associated
price one year ago as inputs. The item could be a kilogram of sugar or
flour, for example. The inflation rate is calculated as the price
difference divided by the previous year's price multiplied by 100. The
estimated inflation rate should be returned as a value of type double
giving the rate in percent, for example, 5.3, if the inflation was
estimated to be 5.3 percent. Here is an example: product price
(previous year in EUR): 1.35; product price (current year in EUR): 1.40;
inflation rate (in percent): (1.40 - 1.35)/1.35*100 = 3.7
We now also want to predict what the new price would be in one year
from the time of calculation given a current price and the estimated
inflation rate. The increase in cost over one year follows from the
estimated inflation rate and the price at the start of the year. Here is an
example: estimated inflation rate (in percent): 3.7; price (current year
in EUR): 1.40; price (next year in EUR): 1.40 + 3.7/100*1.40 = 1.45.
Finally, given the current price, pp, and the inflation rate (in
percent), rr, we want to calculate the price, pnpn, after nn years. The
formula for that is
pn=(1+r/100)n∗ppn=(1+r/100)n∗p
The function prototype is
double estimateNewPrice(double price, double inflation_rate, double
years);
You can also use this formula for the problems above.
AssessmentPart1.cpp
#include "AssessmentPart1.h"
#include <cmath>
d=(p2_x−p1_x)2+(p2_y−p1_y)2−−−−−−−−−−−−−−−−−−−−−−−−−
−√d=(p2_x−p1_x)2+(p2_y−p1_y)2
//Task 2a)
float distance( float p1_x, float p1_y, float p2_x, float p2_y )
{
//add your code for task 1a) here
}
//Task 2b)
bool inside_circle(float c_x, float c_y, float r, float p_x, float p_y)
{
//add your code for task 1b) here
}
//Task 2c)
bool circles_intersect(float c1_x, float c1_y, float r1, float c2_x, float
c2_y, float r2)
{
//add your code for task 1c) here
}
AssessmentPart2.h
//a)
float distance( float p1_x, float p1_y, float p2_x, float p2_y );
//b)
bool inside_circle(float c_x, float c_y, float r, float p_x, float p_y);
//c)
bool circles_intersect(float c1_x, float c1_y, float r1, float c2_x, float
c2_y, float r2);