Help Please

#include <iostream>
void getBalance(float);
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv)
{
float balance =0.0,min,max,deposit=0;
int a,b;
int i;
cout << "DEPOSIT:\t" ;
cin >> balance;
deposit =balance;
cout << "MINIMUM interest rate(in decimal form):\t";
cin >> min;
cout << "MAXIMUM interest rate(in decimal form):\t";
cin >> max;
a = ((max*100) - (min * 100))+1;
for(b=1;b<=a;b++)
{
switch(b)
{
case 1:cout << "Rate "<< b << "%:" << "\n";
for(i=1;i<=3;i++)
{
balance = balance + (balance *(min)) ;
cout << "\t\tYear"<< i <<":\t" << balance << "\n";
}
break;
case 2:cout << "Rate "<< b << "%:" << "\n";
min = min + 0.01;
balance = deposit;
for(i=1;i<=3;i++)
{
balance = balance + (balance *(min)) ;
cout << "\t\tYear"<< i <<":\t" << balance << "\n";
}
break;
case 3:cout << "Rate "<< b << "%:" << "\n";
balance = deposit;
for(i=1;i<=3;i++)
{
balance = balance + (balance *(max)) ;
cout << "\t\tYear"<< i <<":\t" << balance << "\n";
}
break;
}
}
cout << "Initial deposited amount =" ;getBalance(deposit) ;
return 0;
}
void getBalance(float deposit)
{
cout << deposit;
}

1>------ Build started: Project: Intermediate19 Project, Configuration: Debug Win32 ------
1> Intermediate19.cpp
1>c:\cpp8\chap 10\intermediate19 project\intermediate19 project\intermediate19.cpp(17): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
1>c:\cpp8\chap 10\intermediate19 project\intermediate19 project\intermediate19.cpp(30): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1> Intermediate19 Project.vcxproj -> C:\Cpp8\Chap 10\Intermediate19 Project\Debug\Intermediate19 Project.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Error 3 error LNK1168: cannot open C:\Cpp8\Chap 10\Intermediate19 Project\Debug\Intermediate19 Project.exe for writing C:\Cpp8\Chap 10\Intermediate19 Project\Intermediate19 Project\LINK Intermediate19 Project
Sorry, there are no warnings generated by my compiler so far.

1.
min = min + 0.01;
Should be :
min = min + 0.01f;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
void getBalance(float);
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv)
{
float balance =0.0,min,max,deposit=0;
int a,b;
int i;
cout << "DEPOSIT:\t" ;
cin >> balance;
deposit =balance;
cout << "MINIMUM interest rate(in decimal form):\t";
cin >> min;
cout << "MAXIMUM interest rate(in decimal form):\t";
cin >> max;
a = ((max*100) - (min * 100))+1;
for(b=1;b<=a;b++)
{
switch(b)
{
case 1:cout << "Rate "<< b << "%:" << "\n";
for(i=1;i<=3;i++)
{
balance = balance + (balance *(min)) ;
cout << "\t\tYear"<< i <<":\t" << balance << "\n";
}
break;
case 2:cout << "Rate "<< b << "%:" << "\n";
min = min + 0.01;
balance = deposit;
for(i=1;i<=3;i++)
{
balance = balance + (balance *(min)) ;
cout << "\t\tYear"<< i <<":\t" << balance << "\n";
}
break;
case 3:cout << "Rate "<< b << "%:" << "\n";
balance = deposit;
for(i=1;i<=3;i++)
{
balance = balance + (balance *(max)) ;
cout << "\t\tYear"<< i <<":\t" << balance << "\n";
}
break;
}
}
cout << "Initial deposited amount =" ;getBalance(deposit) ;
return 0;
}
void getBalance(float deposit)
{
cout << deposit;
}

2.
a = ((max*100) - (min * 100)) + 1;

Should be :
a = int(((max * 100.0f) - (min * 100.0f)) + 1.0f);
Topic archived. No new replies allowed.