I'm trying to limit the string item1, item2, and item3 to ten letters and if they are longer than ten letters I want the program to produce a statement and terminate the program. I also want to do this with price1, price2, price3, but I haven't tried this yet because I'm stuck on the first part. I assume it should be similar to limiting the first items. How do I do this with a conditional statement? Here's what I have so far:
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
string item1, item2, item3;
int ten;
ten=10;
item1<"10";
item2<"10";
item3<"10";
cout << "Enter names of 3 one-word items to purchase (each name must be less than 10 letters long): " <<endl;
cin >> item1 >> item2 >> item3;
if (item>=10)
{
cout<< "This item is more than 10 letters long" <<endl;
return 0;
}
float price1, price2, price3, thousand;
thousand=1000;
cout << "You have purchased 3 items. Enter their prices in US Dollars (must be less than $1,000): " <<endl;
cin >> price1 >> price2 >> price3;
}