MayDay-Man Overboard

Alrite, thanks for coming to my rescue.
My problem, A const integer is declared and initialised to 250.So when the user enters 200,if the value the user entered was less than the const(250) I want a loop that keeps asking the user to add more to the initial input, 200 until it gets to 250 or more than 250
1
2
3
4
5
6
7
8
9
10
11
12
13
int input;
const int total = 250;

cout<<"Enter input:";
cin>>input;
    if(amount<total_cost){
 
    do{       
                       cout<<"Enter more money: ";
                       cin>>newamount;
                       newamount = newamount + amount;   
    }while(newamount<=total);
    cout<<"Thank you";


what am I doing wrong here...thanks
It is not clear what is input, newamount, amount and total_cost. For example the value of input is not used in your code snip.
Im really sorry,

Okay, so the user enters a value say, 200. A different int total exists where it stores 450.

when the user enters a value say 200, I want to cross-check it with the int total variable and see if its less than 450, if it is I want to keep asking the user to keep entering more until it reaches or is more than 450, keeping in mind the initial values entered by the user.

how do I add all those initial values entered and see if it has reached or is more than 450.....make sense....thanks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const int total_cost = 450;

std::cout << "Enter money: ";

int amount;
std::cin >> amount;

while ( amount < total_cost )
{
   std::cout << "Enter more money: ";

   int extra_amount;
   std::cin >> extra_amount;

   amount += extra_amount;
}
Topic archived. No new replies allowed.