hey guyz how r u??
plzz i rly need ur help with this 1.. coz i dnt know how 2 writ it..:(

Writ a program estimate how much a young worker will make before retiring age of 65. request the worker’s name, age, and starting salary as input. Assume the worker receives a 5 percent raise each year. For example, if the user enters Helen, 25 and 20000, the out put will be:
helen will earn about $2415995

itz about loops..

and thank u very much..

Edited 7 Years Ago by besbis cat: n/a

you know that 5% its integrer * 0.05 right?
just make a for for it.
kind of like.

for(age = input_age;till 65 or else(age < final_age);age++)
{
year_money = money * 0.05;
money = money + year_money; //you can do this one and the one above 
 // in the same line
}
cout << "If you don't eat or drink you have good chance of having: " 
     << money << endl;

Edited 7 Years Ago by gastonci: n/a

hmmm, sorry bt seems itz not write answer..

:angry::angry::angry: Yea well how about this

#include <iostream>
using namespace std;

int main()
{
    string name;
    double money;
    int age;
    double pay;
    cout << "Please enter your name: ";
    getline(cin,name);
    cout << "Enter your age: ";
    cin >> age;
    cout << "Enter the amount of money that you have: ";
    cin >> money;
    cout << "Enter how much money you earn by year: ";
    cin >> pay;
    for(true;age <= 65; age++)
    {
                 pay = pay + (pay * 0.05);
                 money = money + pay;
    }
    cout << "The calculated money is: " << money << endl;
    system("PAUSE");
    return 0;
}

can i ask a Q??
what do u mean here>> system("PAUSE");??
nd im sorry if i bother u..

it's okay :)
and is it okay if i didn't write it?
thank you very much for helping me..

Comments
Very entertaining

Here is your answer. I messed around with my own code on a project I worked on a couple days ago and here is the answer to the problem. Feel free to change any variables you want but make sure you account for them.


Dim age As Double = CDbl(txtAge.Text.ToString)
Dim salary As Double = CDbl(txtSalary.Text.ToString)
Dim name As String = txtName.Text.ToString
Dim results As Double = 0
name = txtName.Text


Do While age < 65

results += (0.05 * salary)
salary += (0.05 * salary)
age += 1

Loop

txtResults.Text = name & " will earn about " & FormatCurrency(results)

Note that the characters after the concatenate character or Ampersand and in quotes will be dark red.

Edited 6 Years Ago by wareagleau: n/a

This article has been dead for over six months. Start a new discussion instead.