Home Forums C Programming Help Please

Viewing 1 reply thread
  • Author
    Posts
    • #2221
      JavierLathrop
      Participant

      I’m pretty new to C Programing and I am trying to make a very basic calculator that calculates interest. If anyone could give me some ideas that would be great because everytime I try running my programs it either spits out a random number or the program freezes.

      Any help would be much appreciated. Thank You.

    • #3602
      GWILouisaxwzkla
      Participant

      could try:


      /****************************************************************
      * File Name : c:programstempCG.cpp
      * Date : August,11,2009
      * Comments : new project
      * Compiler/Assembler : Visual C++ 6.0
      * Modifications :
      *
      *
      *
      *
      *
      * Program Shell Generated At: 2:00:25 p.m.
      =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


      #include
      //#include
      //#include
      //#include
      //#include
      //#include

      using namespace std;

      //main function ******************************

      int main ( )
      {

      int numberYears;
      float interestRate;
      int initialAmount;

      cout << "enter intial amount: ";
      cin >> initialAmount;

      cout << "enter the interest rate: ( rate % ) " ;
      cin >> interestRate;
      interestRate = interestRate / 100;
      cin.get ();

      cout << "enter number of years: ";
      cin >> numberYears;

      cout << "amount plus interest: ";
      cout << initialAmount + ( ( interestRate * initialAmount ) * numberYears ) ;
      cout << endl;



      return 0 ;
      }




      output:


      enter intial amount: 100
      enter the interest rate: ( rate % ) 10%
      enter number of years: 2
      amount plus interest: 120
      Press any key to continue

Viewing 1 reply thread
  • The forum ‘C Programming’ is closed to new topics and replies.