needing help figuring out

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2006
Posts: 13
Reputation: caseg is an unknown quantity at this point 
Solved Threads: 0
caseg caseg is offline Offline
Newbie Poster

needing help figuring out

 
0
  #1
Feb 27th, 2006
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);
}
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,055
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: needing help figuring out

 
3
  #2
Feb 27th, 2006
Huh? What are you trying to do here?
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 13
Reputation: caseg is an unknown quantity at this point 
Solved Threads: 0
caseg caseg is offline Offline
Newbie Poster

Re: needing help figuring out

 
0
  #3
Feb 27th, 2006
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......
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 13
Reputation: caseg is an unknown quantity at this point 
Solved Threads: 0
caseg caseg is offline Offline
Newbie Poster

Re: needing help figuring out

 
0
  #4
Feb 27th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 505
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Solved Threads: 51
Bench's Avatar
Bench Bench is offline Offline
Posting Pro

Re: needing help figuring out

 
0
  #5
Feb 27th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 1415 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC