Data Validation

How can we do data validation in bloodshed dev c++, in a if else statement??
how can we implement data validation in the program given below,
data validation for category,
previous meter reading should be less than current meter reading.

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
//Title of the Program
cout<<"\t*********************************************************"<<endl;
cout<<"\t\tEXOTIC ELETRICITY SUPPLIES BILL CALCULATOR"<<endl;
cout<<"\t*********************************************************\n"<<endl;

//declare the constant and varibles
double previous_mr = 0.0;
double current_mr = 0.0;
double total_mr = 0.0;
double total_VEP = 0.0;
double total_bill = 0.0;
double vat = 0.0;
double average = 0.0;
double govt_subsidy = 0.0;
double totalgovt_subsidy = 0.0;
double excess_mr = 0.0;
string acc_number;
string full_name;
string address;
string period_date;
char category = ' ',D,d,C,c;
const double VAT = 0.15;
const double period_mr = 30;
system("COLOR f2");


//Enter the Choice
cout<<"Please enter 'D' for Domestic Customer or 'C' for Commercial Customer: "<<endl;
cin>>category;
cout<<"\n[Please use underscore for space (e.g. Rajesh_Chand)]"<<endl;
cout<<"\nPlease enter Client Name: "<<endl;
cin>>full_name;
cout<<"Please enter Client Address: "<<endl;
cin>>address;
cout<<"Please enter the Account Number: "<<endl;
cin>>acc_number;
cout<<"Please enter Period of Meter Reading (Date): "<<endl;
cin>>period_date;
cout<<"Please enter the Current Meter Reading: "<<endl;
cin>>current_mr;
cout<<"Please enter the Previous Meter Reading: "<<endl;
cin>>previous_mr;

//Calculation for Domestic Customer

total_mr = current_mr - previous_mr;

if(category == 'D' || category == 'd')

if (total_mr <= 75)
{
total_VEP = total_mr * 0.1720;
vat = total_VEP * VAT;
total_bill = vat + total_VEP;
govt_subsidy = total_mr * 0.1764;
vat = govt_subsidy * VAT;
totalgovt_subsidy = govt_subsidy + vat;
average = total_mr / period_mr;
}
else
{
total_VEP = total_mr * 0.3484;
vat = total_VEP * VAT;
total_bill = vat + total_VEP;
average = total_mr / period_mr;
}

else if(category == 'C' || category =='c')

if(total_mr <= 14999)
{
total_VEP = total_mr * 0.42;
vat = total_VEP * VAT;
total_bill = vat + total_VEP;
average = total_mr / period_mr;
}
else
{
excess_mr = total_mr - 14999;
total_VEP = (14999 * 0.42)+(excess_mr * 0.44);
vat = total_VEP * 0.15;
total_bill = vat + total_VEP;
average = total_mr / period_mr;
}

//Customer Details and bill charges
cout<<"\nCustomer: "<<full_name<<endl;
cout<<"Address: "<<address<<endl;
cout<<"Client Category: "<<category<<endl;
cout<<"Billing Period: "<<period_date<<endl;
cout<<"Units Consumed: "<<total_mr<<endl;
cout<<"Average Daily Usage: "<<average<<endl;
cout<<fixed;
cout<<setprecision(2)<<"Total Billing (VEP): $"<<total_VEP<<endl;
cout<<setprecision(2)<<"Government Subsidy: $"<<totalgovt_subsidy<<endl;
cout<<setprecision(2)<<"Total Vat: $"<<vat<<endl;
cout<<setprecision(2)<<"Total Bill: $"<<total_bill<<endl;



system("PAUSE");
return 0;

}
Topic archived. No new replies allowed.