tutor is needed here plz.

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

Join Date: Apr 2009
Posts: 63
Reputation: fadia is an unknown quantity at this point 
Solved Threads: 0
fadia fadia is offline Offline
Junior Poster in Training

tutor is needed here plz.

 
0
  #1
Jun 23rd, 2009
Hello.. can someone teach me how to do this program.

This is the question.

1. An organization has aprox. $1000 available to be allocated in small amount to approved charities. Write a program that will read several amounts and ((report as soon as over $1000 has been allocated. << NOW this is the part that i didn't know how to do!))

2. Display the number of donations required to exceed $1000.
For example in the output ATTACHED this message should be displayed: "4 donations were made" << this also didn't know how to do it.

Please note that i didn't take arrays yet.. so i'm not suppose to use them.. i only took loops, if-else, switch, and functions.

This is what i know.. so far:
  1. # include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. int x,i=0;
  7.  
  8. do
  9. {
  10.  
  11. cout<<"Please enter an amount: ";
  12. cin>>x;
  13.  
  14. i++;
  15.  
  16. }while(x<=1000);
  17.  
  18. return 0;
  19. }
Attached Thumbnails
piC!!DANI.jpg  
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: tutor is needed here plz.

 
0
  #2
Jun 23rd, 2009
what your code currently does is, it stops when any single amount is greater than 1000. you need to come up with a way to "keep track" of what has already been allocated.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 63
Reputation: fadia is an unknown quantity at this point 
Solved Threads: 0
fadia fadia is offline Offline
Junior Poster in Training

Re: tutor is needed here plz.

 
0
  #3
Jun 23rd, 2009
i'm already aware of that and have been thinking of a way to do so.. but didn't know how!!
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: tutor is needed here plz.

 
0
  #4
Jun 23rd, 2009
do you know the concept of a counter variable? perhaps it will help you.

using a single variable x, you can only store the current value. you need to be able to store a cummulative values (which will be stored in your counter).

hope that helps
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 63
Reputation: fadia is an unknown quantity at this point 
Solved Threads: 0
fadia fadia is offline Offline
Junior Poster in Training

Re: tutor is needed here plz.

 
0
  #5
Jun 23rd, 2009
i have a counter in the program..
it's i++
but i'm not sure if i used it the right way.
Last edited by fadia; Jun 23rd, 2009 at 3:37 am. Reason: spelling mistake
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: tutor is needed here plz.

 
0
  #6
Jun 23rd, 2009
no, it's definitely not the right way. for a start, the counter should form your loop's condition statement (hint 1). furthermore, even if you were using your counter as part of the condition it would only check the number of allocations you have done, not the actual value allocated (hint 2).

have a think for a while, don't just reply in hope of getting code.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 63
Reputation: fadia is an unknown quantity at this point 
Solved Threads: 0
fadia fadia is offline Offline
Junior Poster in Training

Re: tutor is needed here plz.

 
-1
  #7
Jun 23rd, 2009
ur not being helpful here at all... thnx for ur hint and all
but i didn't understand a singal thing from u

thnx though.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: tutor is needed here plz.

 
1
  #8
Jun 23rd, 2009
I get the impression you aren't really trying here, produce some updated code with what you are trying...

maybe then I can give more assisstance.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 14
Reputation: auhuman has a little shameless behaviour in the past 
Solved Threads: 0
auhuman auhuman is offline Offline
Newbie Poster

Re: tutor is needed here plz.

 
-3
  #9
Jun 23rd, 2009
hey fadia, i think this wil work 4 ur need.
#include <iostream>

using namespace std;

int main ()
{
int x=0,Donate=0,i=0,l=1;
while(l==1)
{
if(Donate<1000)
{
cout<<"Please enter amount 4 DoantionNo: "<<i+1<<" ";
cin>>x;
Donate=Donate+x;
i++;
}
else
{
l=0;
cout<<"$"<<(Donate-1000)<<" over $1000 has been allocated in "<<i+1<<" number of donations";
}
}
cin>>x;
return 0;
}
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 675
Reputation: Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold 
Solved Threads: 99
Sky Diploma's Avatar
Sky Diploma Sky Diploma is offline Offline
Practically a Master Poster

Re: tutor is needed here plz.

 
0
  #10
Jun 23rd, 2009
auhuman, Though you have made 4 posts, You have been here for about 4 month's i believe, So It is of the impression that you must be knowing about the workings of this forum.
Basic Rule On Homework Help
Though your motive was to help Fadia out, It should have been done by telling him what he had to accomplish and how can he do so , But, not by giving away code.

Secondly, In the code you have given, I think that the variable in the while loop l can be completely avoided, Or Should have been replaced by a type bool
1. Please Mark Your Thread as Solved After Getting Your Answers.
2. Please Use CODE TAGS .
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC