# Answer to Question #12073 in C++ for Mindy Smith

Question #12073

What are the C++ Instructions for this problem?

At the beginning of every year, the Computer Programmer receives a raise on his/her previous year's salary. He/she wants a program that calculates and displays the amount of his annual raises for the next three years, using rates of 2%, 3%, 4% and 5%. The program should end when the programmer enters a sentinel value as the salary.

At the beginning of every year, the Computer Programmer receives a raise on his/her previous year's salary. He/she wants a program that calculates and displays the amount of his annual raises for the next three years, using rates of 2%, 3%, 4% and 5%. The program should end when the programmer enters a sentinel value as the salary.

Expert's answer

#include "stdafx.h"

#include <iostream.h>

#include <math.h>

float salary=1;

void main(){

while (salary != 0){

printf("\nEnter the salary amount or 0 to exit: ");

scanf("%f", &salary);

if (salary != 0){

& printf("\n%*d%% %*d%% %*d%% %*d%%\n", 19, 2, 9, 3, 9, 4, 9, 5);

& printf("1st year: %*0.2f %*0.2f %*0.2f %*0.2f\n", 1, salary*1.02, 1, salary*1.03, 1, salary*1.04, 1, salary*1.05 );

& printf("2nd year: %*0.2f %*0.2f %*0.2f %*0.2f\n", 1, salary*pow(1.02,2), 1, salary*pow(1.03,2), 1, salary*pow(1.04,2), 1, salary*pow(1.05,2) );

& printf("3rd year: %*0.2f %*0.2f %*0.2f %*0.2f\n", 1, salary*pow(1.02,3), 1, salary*pow(1.03,3), 1, salary*pow(1.04,3), 1, salary*pow(1.05,3) );

& }

}

}

#include <iostream.h>

#include <math.h>

float salary=1;

void main(){

while (salary != 0){

printf("\nEnter the salary amount or 0 to exit: ");

scanf("%f", &salary);

if (salary != 0){

& printf("\n%*d%% %*d%% %*d%% %*d%%\n", 19, 2, 9, 3, 9, 4, 9, 5);

& printf("1st year: %*0.2f %*0.2f %*0.2f %*0.2f\n", 1, salary*1.02, 1, salary*1.03, 1, salary*1.04, 1, salary*1.05 );

& printf("2nd year: %*0.2f %*0.2f %*0.2f %*0.2f\n", 1, salary*pow(1.02,2), 1, salary*pow(1.03,2), 1, salary*pow(1.04,2), 1, salary*pow(1.05,2) );

& printf("3rd year: %*0.2f %*0.2f %*0.2f %*0.2f\n", 1, salary*pow(1.02,3), 1, salary*pow(1.03,3), 1, salary*pow(1.04,3), 1, salary*pow(1.05,3) );

& }

}

}

## Comments

## Leave a comment