I have to use a while loop to display everything 3 times and then i have to use a do while loop to do the same thing
when i added my while and do while loop it keeps on repeating like a millions times and i cant stop it can someone please help me
// Description: Display person name, address, calculated and
// actual cost of car and color of car
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <iomanip.h>
int x;
char st_name[25];
char st_address[75];
char st_color[25];
float f_ccost;
float f_acost;
void getdata();
void processdata();
void putdata();
int main()
{
for(x=1;x<=3;x++)
{
getdata();
processdata();
putdata();
}
}
void getdata()
{
cout << "\n\nPlease enter your name: ";
cin.getline(st_name,25);
cout << "\n\nPlease enter your address: ";
cin.getline(st_address,75);
cout << "\n\nPlease enter the amount you paid for your car: ";
cin >> f_acost;
cin.get();
cout << "\n\nPlease enter your car color: ";
cin.getline(st_color,25);
}
void processdata()
{
cout << "\n\nCalculated amount of your car is: ";
if(f_acost < 1200)
{
if(strcmp(st_color,"blue")==0)
{
f_ccost = f_acost + 10.0/100;
cout << f_ccost;
}
else
{
cout << f_acost;
}
}
else if(f_acost > 1000.00 && f_acost < 1500.00)
{
if(strcmp(st_color,"black")==0)
{
f_ccost = f_acost + 2.0/100;
cout << f_ccost;
}
else
{
cout << f_acost;
}
}
else if(f_acost <= 2000.00)
{
if(strcmp(st_color,"white")==0)
{
f_ccost = f_acost - 500.00;
cout << f_ccost;
}
else
{
cout << f_acost;
}
}
else
{
cout << f_acost;
}
}
void putdata()
{
cout << "\n\nPerson Name: " << st_name;
cout << "\n\nAddress: " << st_address;
cout << setiosflags(ios::fixed)
<< setiosflags(ios::showpoint)
<< setprecision(2);
cout << "\n\nActual Cost of Car: $ " << f_acost;
cout << "\n\nCalculated Cost of Car: $ " << f_ccost;
cout << "\n\nColor of Car: " << st_color;
}