The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I need help adding on to my C program. it can't be C+, has to be regular C. This is what I have so far:
#include
main ()
{
int num_years; float ror, interest_earned, total, investment; double arr[10];
while(1)
{
printf("Enter the initial investment: $");
scanf("%lf", &arr[0]);
if(arr[0] > 0 && arr[0] <= 5000) break;
else printf("Amount not in rangen");
}
printf("n Please enter the number of years left to retire n");
fflush(stdin);
scanf("%d",&num_years);
if(num_years<1||num_years>50)
{
printf("Enter value between 1 and 50");
scanf("%d",&num_years);
}
printf("n Please enter the assumed rate of return on the investment n");
scanf("%f",&ror);
if(ror<-15 or ror>15)
{
printf("Enter value between -15 and 15");
scanf("%f",&ror); }
printf("Enter the initial investment: $");
scanf("%f", &investment);
interest_earned=(float)(investment*ror*num_years)/100;
printf("The interest on your investment %f is %f n",investment, interest_earned);
total=investment+interest_earned;
printf("You will recieve the amount %f at the time of retirement n",total);
}
What would I write to prevent any calculations if any of the previous three values are invalid and then once a valid value has been entered into element zero of the float array, copy the starting value into element zero of the second array. (second float array must be created)