first of all thnx for trying to help me.....this is a part of my program......i want to know how to put validations while inputting the data in main()....thnx
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
int i;
class product //start of class
{
int itemno;
char name[100];
char itemtype[50];
float price;
float quantity;
float total;
public:
void addprod() ;
void calculate();
void accept();
void display() ;
} ; //end of class
void product::addprod() //starting of addproduct()
{
cout<<"enter the serial number";
cin>>itemno;
cout<<"enter the name of the poduct:";
gets(name) ;
cout<<"enter its type:";
gets(itemtype);
***cout<<"enter its price:";
cin>>price;**
}* //end of addproduct()
void product::accept() //starting of accept()
{
cout<<"enter the item name:";
gets(name) ;
cout<<"enter the quantity:";
cin>>quantity;
}
void product::calculate()
{
total=price*quantity;
}
void product::display()
{
cout<<"\nName";
cout<<name;
cout<<"\nPrice";
cout<<price ;
cout<<"\nquantity";
cout<<quantity;
cout<<"\ntotal\n\n\n\n\n";
cout<<total;
}
void main()
{
int ch;
product s1[3];
a:
cout<<"\n 1. Add product one by one";
cout<<"\n 2. Add products in bulk";
cout<<"\n 3. Make Bill";
cout<<"\n 4. Display Bill";
cout<<"\n 0. Exit";
cout<<"\n Enter your choise(1,2,3,9)" ;
cin>>ch;
switch(ch)
{
**case 1: cout<<"\n press n to exit\n\n";
char con='y';
while(con=='y')
{
s1[i].addprod();
i++;
cout<<"do u wanna continue(y/n)";
cin>>con;
if(con=='n')
{
goto a;
}
}
break;
}**
This is my school project so need help as soon as possible. like if a person enters a character(a,b,c) so what should i do to make him aware its a wrong input and asks the user to input the correct form