issues with looping

I'm trying to make this code be able to continue looping through until the customer is done shopping and then be able to print how many of each shoe they bought (quantity and product name). I already can get it to print the total price, but I cannot figure out a way to make it print the name and quantity of each shoe they're buying.
<code>
#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <fstream>
#include <string.h>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{
string firstname; // need to make 2 variables for the first and last name, the code automatically looks for a space to separate the variables
string lastname;
cout << "Enter your first and last name:" << endl;
cin >> firstname >> lastname;
string phonenumber; // single variable for a single number, used string instead of int because int can only handle an 8 digit number
cout << "Enter your phone number with no spaces:" << endl;
cin >> phonenumber;
string address; // 7 part address, ie 123 South Shore Road, Miami, Florida 11111 - most common address type in existence.
cout << "Enter your full address with no punctuation:" << endl;
cin.ignore();
getline(cin, address);
string ccard; // string again, as it can handle multiple characters
cout << "Enter your credit card number:" << endl;
cin >> ccard;
string expdate; // string as it can handle characters and non-numerical characters
cout << "Enter your credit card expiration date in month/year format:" << endl;
cin >> expdate;
string cid; // could have used int but used string again just for homogeneity
cout << "Enter your CID:" << endl;
cin >> cid;
cout << "Thank you for visiting our website today, " << firstname << " " << lastname << ". Below you will find a list of products available for purchase at this time.";
cout << " Please enjoy your visit on our website." << endl; // welcome message as required
int search; // made search an int so that i can use it as an if else statement easily

int skechers; // make skechers and nike a variable
int nike;
int saucony;
int adidas;
int vans;
int converse;
int size;
int athoptions;
int quantity;
int total;
int final;
final = 0;
skechers = 55;
nike = 60;
saucony = 90;
adidas = 80;
vans = 100;
converse = 100; // set variables to their prices and create variables for the purchasing loop

char choice;
do {
cout << "Our categories are as follows: Athletic Shoes, Track Shoes, Casual Shoes. \n choose option 1, 2, or 3" << endl; // user chooses a number corresponding to category
cin >> search; // this wasn't required but I liked how it narrowed down options, I could/probably will populate these options further, and will possibly add in more categories

if (search == 1) {
cout << "Nike Running Shoes, sizes 8-13, blue/grey, $60" << endl;
cout << "Skechers Shape ups, Women's sizes 3-10, pink/green, $55" << endl; // two different athletic shoe options
cout << "Do you want Nike or Skechers? Choose option 1 or 2" << endl; // ask which shoes they want to buy
cin >> athoptions;
if (athoptions == 1) {
cout << "What size do you want? Sizes 8-13" << endl; // ask which size the user wants
cin >> size;
cout << "How many do you want?" << endl; // ask how many the user wants
cin >> quantity;
total = quantity * nike;
}
else if (athoptions == 2) {
cout << "What size do you want? Women's sizes 3-10" << endl; // ask which size user wants
cin >> size;
cout << "How many do you want?" << endl; // ask how many the user wants
cin >> quantity;
total = quantity * skechers;
}
}
else if (search == 2) {
cout << "Saucony Track shoes with .5 inch spikes, sizes 8-13, red/white/silver, $90" << endl;
cout << "Adidas Long Distance Track shoes with .25 inch spikes, sizes 8-13, green/gold, $80" << endl; // two different track shoe options
cout << "Do you want Saucony or Adidas? Choose option 1 or 2" << endl; // ask which shoes they want to buy
cin >> athoptions;
if (athoptions == 1) {
cout << "What size do you want? Sizes 8-13" << endl; // ask which size the user wants
cin >> size;
cout << "How many do you want?" << endl; // ask how many the user wants
cin >> quantity;
total = quantity * saucony;
}
else if (athoptions == 2) {
cout << "What size do you want? Sizes 8-13" << endl; // ask which size the user wants
cin >> size;
cout << "How many do you want?" << endl; // ask how many the user wants
cin >> quantity;
total = quantity * adidas;
}
}
else if (search == 3) {
cout << "Vans, sizes 8-13, white, $100" << endl;
cout << "Converse, sizes 8-13, black/white, $100" << endl; // two different casual shoe options
cout << "Do you want Vans or Converse? Choose option 1 or 2" << endl; // ask which shoes they want to buy
cin >> athoptions;
if (athoptions == 1) {
cout << "What size do you want? Sizes 8-13" << endl; // ask which size the user wants
cin >> size;
cout << "How many do you want?" << endl; // ask how many the user wants
cin >> quantity;
total = quantity * vans;
}
else if (athoptions == 2) {
cout << "What size do you want? Sizes 8-13" << endl; // ask which size the user wants
cin >> size;
cout << "How many do you want?" << endl; // ask how many the user wants
cin >> quantity;
total = quantity * converse;
}
}
else {
cout << "Invalid category number"; // what happens if 1, 2, or 3 are not selected
}
final = final + total;
cout << "Do you want to continue shopping? Y/N" << endl;
cin >> choice;
} while (choice == 'Y');
cout << "Your total purchase today is $" << final << ". Thank you for shopping with us. Your shoes will be shipped in 3-5 business days";
return 0;
}
</code>
Last edited on
also sorry in advance, not sure what i'm doing wrong but it's for some reason not putting it into code even though i did the <code> and </code>
still could use some help with this.
<code> and </code>
is wrong.

Repalce < with [ , and > with ]
Last edited on
Topic archived. No new replies allowed.