Question #181315

Write a program that ask user to enter type. Print "Credit Card" if the type is CC, and if the type is CS print "Cash". Otherwise, print "Invalid Payment".


Expert's answer

using namespace std;


main(void)
{
	char text[2],Flag=0;
	string s;
  	cout <<"\nEnter CC for Credit Card or CS for Cash: ";
  	cin>>text;
  	s=text;
  	if(s=="CC" || s=="cc" || s=="cC" || s=="Cc")		{Flag=1; cout<<"\n\tCredit Card";}
  	if(s=="CS" || s=="cs" || s=="cS" || s=="Cs")		{Flag=1; cout<<"\n\tCash";}
  	if(Flag==0) cout<<"\n\tInvalid Payment";
  	return(0);
}
LATEST TUTORIALS
APPROVED BY CLIENTS