hi, i can figure out why this program keeps counting up the cash variable more than once when i run it, like it'll be
10
10
10
10
10
11
11
11
11
11

and the percentage numbers have the letter "e" at the end of each percentage...

just seeing if i could get a hand cause i am stumped :(


// Produce a two-column table with column headings showing P% if the amounts$ 1$,2$,3$,...,20$. P is to be input,
____________________________________________________________________________________________________________________________________________________________


#include <iostream.h>
#include <conio.h>


int main()
{
double percentage,num2;


cout<<"Please insert percentage: ";
cin>>percentage;
num2=percentage*.01;

for(double cash=1;cash<=20;cash=cash+1)
{
num2=num2*cash;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;
cout.width(10);cout<<cash<<endl;
cout<<num2<<endl;

}
cout<<endl;
return(0);
}

Huh? What are you trying to do here?

well i am supposed to multiple my cin>> variable by .01, and you have to figure out the percentage of the dollars 1-20 for the variable X .01......

pretty much on the left i must have the input*.01*cash(the one to the righ of it)
and on the right ill have the cash number

The whole idea of 'for' loops is that you type the code once, and the loop will repeat it. The reason you are getting the same output multiple times is that you have the same 2 lines occurring 20 times.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.