1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AVprozaik [17]
3 years ago
9

Write a program that outputs inflation rates for two successive years and whether the inflation is increasing or decreasing. Ask

the user to input the current price of an item and its price one year and two years ago. To calculate the inflation rate for a year, subtract the price of the item for that year from the price of the item one year ago and then divide the result by the price a year ago. Your program must contain at least the following functions: a function to get the input, a function to calculate the results, and a function to output the results. Use appropriate parameters to pass the information in and out of the function. Do not use any global variables.
Computers and Technology
1 answer:
MrRissso [65]3 years ago
8 0

Answer:

#include

using namespace std;

void getInput(double currentPrice, double priceYear1, double priceYear2){

   cin >> currentPrice;

   cin >> priceYear1;

   cin >> priceYear2;

}

void printInflationRate( double myRate){

   cout<< "The inflation rate for the year price = "<< rate;

}

void calInflation(double targetPrice, double yearBefore){

   double rate = (yearBefore - targetPrice)/ yearBefore;

   printInflationRate( rate);

}

int main(){

   double cprice, year1price, year2price, rate;

   getInput(cprice, year1price, year2price);

   calInflationRate(cprice, year1price);

   calInflationRate(year1price, year2price);

   return 0;

}

Explanation:

The C++ program source code defines three void functions (functions with no return statement), 'calInflationRate', 'getInput', and printInflationRate. In the main program code, the four float point number variables are declared, and the getInput function assigns values to them. The calInflationRate function calculates the inflation rate of a given year, and it in, the printInflationRate is called to print the output on the screen.

You might be interested in
Most keyboards today are in a
BlackZzzverrR [31]
Qwerty format I think.
6 0
3 years ago
¿Que es la energía? (una sola respuesta es la correcta)
kozerog [31]

Answer:

es la a ya que la luz actua en un cuerpo

8 0
3 years ago
¿Por qué disminuyó el tamaño de la población de caribús? Usa la evidencia inicial para explicar por qué disminuyó el tamaño de l
scZoUnD [109]

Climate change, habitat destruction, and over-harvesting leading to a decrease in caribou populations. ... There are many possible causes of this decline, including: habitat destruction, climate change, and over harvesting.

7 0
2 years ago
Question 9/10
Firlakuza [10]
They sometimes offer free service
5 0
3 years ago
Read 2 more answers
(True or False) The speed at which data travels on a bus is referred to as the word size.
geniusboy [140]

Answer:

True

Explanation:

4 0
2 years ago
Read 2 more answers
Other questions:
  • On sites that use "cloud computing," how is your information being stored?
    13·1 answer
  • How many buttons does a gamecube controller have?
    7·1 answer
  • What do you click to create a new presentation in Normal view
    14·1 answer
  • In this website/app what are the points for?
    7·1 answer
  • You can install several printers on your machine, but at least one must be the _______ printer.
    6·1 answer
  • Write a method called makeLine. The method receives an int parameter that is guaranteed not to be negative and a character. The
    11·1 answer
  • Two technicians are discussing a resistance measurement. Technician A states that components being measured should be removed or
    10·1 answer
  • ABC software company is to develop software for effective counseling for allotment of engineering seats for students with high s
    13·1 answer
  • Which result is most likely if a network packet has no header?
    9·2 answers
  • Which of the following is constantly changing and advancing?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!