Tuesday, July 14, 2009

C++ need help changing a prog.?

this is my current program i need to change it so i can input the years.





#include%26lt;cmath%26gt;


#include%26lt;string%26gt;


#include%26lt;iostream%26gt;





using namespace std;





int main()


{





double total, uncut;


const double restrate=.02;





total = 14000;


uncut = 2500;





cout %26lt;%26lt; "Year..............Acres" %26lt;%26lt; endl %26lt;%26lt; endl;





for(int k=0; k%26lt;20; k++)


{


cout %26lt;%26lt; k+1 %26lt;%26lt; ".............." %26lt;%26lt; uncut %26lt;%26lt; endl;





uncut += restrate * uncut;


}





getchar();





return 0;


}

C++ need help changing a prog.?
Prompt the user to inpu the data u want. cout out a statement asking to input the data then use cin to get the input.





To do this u need to type





cin%26gt;%26gt;"data";





after prompting the input


this will set ur input data to equal the variable for the data. Put this in the input section of your program. You would do it like this, lets call the new variable "data":





#include%26lt;cmath%26gt;


#include%26lt;string%26gt;


#include%26lt;iostream%26gt;





using namespace std;





int main()


{





double total, uncut;


const double restrate=.02;


double data=0;





total = 14000;


uncut = 2500;





cout%26lt;%26lt;"Input the data needed"%26lt;%26lt;endl; //this will promt the data to be entered


cin%26gt;%26gt;data; //this will recive the data





cout %26lt;%26lt; "Year..............Acres" %26lt;%26lt; endl %26lt;%26lt; endl;





for(int k=0; k%26lt;20; k++)


{


cout %26lt;%26lt; k+1 %26lt;%26lt; ".............." %26lt;%26lt; uncut %26lt;%26lt; endl;





uncut += restrate * uncut;


}





getchar();





return 0;


}


No comments:

Post a Comment