| | |
tutor is needed here plz.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2009
Posts: 63
Reputation:
Solved Threads: 0
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:
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:
C++ Syntax (Toggle Plain Text)
# include <iostream> using namespace std; int main () { int x,i=0; do { cout<<"Please enter an amount: "; cin>>x; i++; }while(x<=1000); return 0; }
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.
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
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
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.
have a think for a while, don't just reply in hope of getting code.
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.
maybe then I can give more assisstance.
•
•
Join Date: Feb 2009
Posts: 14
Reputation:
Solved Threads: 0
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;
} 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
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 ![]() |
Similar Threads
- Seminar topic needed (IT Professionals' Lounge)
- C++ tutor needed (C++)
- Urgent help needed......Plz somebody help me..... (Windows NT / 2000 / XP)
- Java tutor needed BADLY (Java)
- Audio Driver -extreme Urgent Help Needed Plz (Motherboards, CPUs and RAM)
Other Threads in the C++ Forum
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





