Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6767817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:59:47+00:00 2026-05-26T14:59:47+00:00

I am writing a program for a class I am taking. I am having

  • 0

I am writing a program for a class I am taking. I am having problems getting the proper output. I have programmed many times before and usually I would make my method declarations global. However our professor told us that we are not allowed to have global functions. All of our functions must be declared in the Main loop. Below is the loop that calls on the two primary functions. The first one runs a calculation. The other one displays the output to the screen. The problem is that the program is not doing the calculation multiple times but instead outputs the same number multiple times. Any help is greatly appreciated.

The loop:

 for ( YearNumber = 1; YearNumber <= Years; YearNumber++)   
       {

        /*--------------------------------------------------*/
        /*                                                  */
        /* Call ComputeFutureValue Function                 */
        /*                                                  */  
        /*--------------------------------------------------*/

        ComputeFutureValue (Principle, OnePlusInterestRate, YearNumber);

        /*--------------------------------------------------*/
        /*                                                  */
        /* Call DisplayYearInfo Function                    */
        /*                                                  */
        /*--------------------------------------------------*/

        DisplayYearInfo (YearNumber, FutureValue);  

       }

The Compute Function:

float ComputeFutureValue (float Principle, float OnePlusInterestRate, int YearNumber)
{
 float FutureValue = Principle * pow (OnePlusInterestRate, YearNumber);

}

The display method:

 void DisplayYearInfo (int YearNumber, float FutureValue)

{

cout << setw (2)
     << YearNumber
     << setw (22)
     << FutureValue
     << "\n";

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:59:48+00:00Added an answer on May 26, 2026 at 2:59 pm

    your ComputeFutureValue doesn’t return anything – it only declares a local variable that won’t be visible outside of the function.

    for ( YearNumber = 1; YearNumber <= Years; YearNumber++)   
    {
    
      float FutureValue = ComputeFutureValue (Principle, OnePlusInterestRate, YearNumber);
    
    
      DisplayYearInfo (YearNumber, FutureValue);  
    
    }
    
    
    float ComputeFutureValue (float Principle, float OnePlusInterestRate, int YearNumber)
    {
      return Principle * pow (OnePlusInterestRate, YearNumber);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program to find adapters, and have made a class called
Currently I am writing a program for an introductory Java class. I have two
I'm writing a program for class, and I'm wondering about the output for a
I'm writing a program for my intro to Java class. I'm getting an error
I'm writing a simple program. There is only one class in it. There is
Suppose we are writing a class (let's call it Class) in an iPhone program.
Heyo, My class at college has us writing programs in assembly. I have never
Im writing a program that should read input via stdin, so I have the
I am writing a program for class that is asking us to create a
I am writing a program that creates a stack using linked lists. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.