Consider the table in this picture. This is our data for the program.
Suppose the company asked you to create a program for them that would customers to input information about their order and be given a quote for the total.
#include <iostream>
#include <string>
#include <limits>
using namespace std;
double sideprint, shirts, shirtPrice1;
string shirtSize;
void bulkPrice() {
cout << "How many shirts would you like to buy?: ";
cin >> shirts;
if (shirts >= 12 && shirts <= 24) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 19.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 19.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 21.64; }
}
if (shirts >= 25 && shirts <= 49) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 9.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 9.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 11.64; }
}
if (shirts >= 50 && shirts <= 199) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 7.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 8.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 9.65; }
}
if (shirts >= 200 && shirts <= 299) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 6.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 7.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 8.65; }
}
}
void bulkPrice2() {
cout << "How many shirts would you like to buy?: ";
cin >> shirts;
if (shirts >= 12 && shirts <= 24) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 20.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 21.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 22.64; }
}
if (shirts >= 25 && shirts <= 49) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 11.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 11.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 12.64; }
}
if (shirts >= 50 && shirts <= 199) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 9.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 10.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 11.65; }
}
if (shirts >= 200 && shirts <= 299) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 8.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 9.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 10.65; }
}
}
void bulkPrice3() {
cout << "How many shirts would you like to buy?: ";
cin >> shirts;
if (shirts >= 12 && shirts <= 24) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 21.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 22.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 23.64; }
}
if (shirts >= 25 && shirts <= 49) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 12.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 12.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 13.64; }
}
if (shirts >= 50 && shirts <= 199) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 10.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 11.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 12.65; }
}
if (shirts >= 200 && shirts <= 299) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 9.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 10.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 11.65; }
}
}
void bulkPrice4() {
cout << "How many shirts would you like to buy?: ";
cin >> shirts;
if (shirts >= 12 && shirts <= 24) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 22.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 23.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 24.64; }
}
if (shirts >= 25 && shirts <= 49) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 13.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 13.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 14.64; }
}
if (shirts >= 50 && shirts <= 199) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 11.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 12.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 13.65; }
}
if (shirts >= 200 && shirts <= 299) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 10.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 11.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 12.65; }
}
}
void bulkPrice5() {
cout << "How many shirts would you like to buy?: ";
cin >> shirts;
if (shirts >= 12 && shirts <= 24) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 23.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 24.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 25.64; }
}
if (shirts >= 25 && shirts <= 49) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 14.69; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 14.99; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 15.64; }
}
if (shirts >= 50 && shirts <= 199) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 12.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 13.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 14.65; }
}
if (shirts >= 200 && shirts <= 299) {
cout << "What size?: ";
cin >> shirtSize;
if (shirtSize == "youth") {
shirtPrice1 = 11.70; }
if (shirtSize == "small" || shirtSize == "medium" || shirtSize == "large" || shirtSize == "XL") {
shirtPrice1 = 12.00; }
if (shirtSize == "2XL" || shirtSize == "5XL" || shirtSize == "5XL" || shirtSize == "5XL") {
shirtPrice1 = 13.65; }
}
}
void total() {
double grandTotal = ( sideprint * shirts * shirtPrice1 );
cout << "\nYour total is: $" << grandTotal << "\n";
}
int main() {
char choice, newChoice2;
int newChoice;
do {
cout << "\nSelect an option from below:\n";
cout << "_____________________________\n";
cout << "a. 1 Side Print\n";
cout << "b. 2 Side Print\n";
cout << "x. Exit\n";
cout << "Please make a selection: ";
cin >> choice;
switch (choice)
{
case 'a':
sideprint = 1;
cout << "\nNumber of colors in the print? \n";
cout << "1. 1 Color Print\n";
cout << "2. 2 Color Print\n";
cout << "3. 3 Color Print\n";
cout << "4. 4 Color Print\n";
cout << "5. 5 Color Print\n";
cin >> newChoice;
switch (newChoice)
{
case 1:
bulkPrice();
total();
break;
case 2:
bulkPrice2();
total();
break;
case 3:
bulkPrice3();
total();
break;
case 4:
bulkPrice4();
total();
break;
case 5:
bulkPrice5();
total();
break;
default: cout << "Please select the correct option.\n"; }
break;
case 'b':
sideprint = 3;
cout << "\nNumber of colors in the print? \n";
cout << "1. 1 Color Print\n";
cout << "2. 2 Color Print\n";
cout << "3. 3 Color Print\n";
cout << "4. 4 Color Print\n";
cout << "5. 5 Color Print\n";
cin >> newChoice;
switch (newChoice)
{
case 1:
bulkPrice();
total();
break;
case 2:
bulkPrice2();
total();
break;
case 3:
bulkPrice3();
total();
break;
case 4:
bulkPrice4();
total();
break;
case 5:
bulkPrice5();
total();
break;
default: cout << "Please select the correct option.\n"; }
break;
break;
case 'x':
exit(0);
default:
cout << "Please select the correct option.\n" ;
break;
}
} while (choice != 'x');
}
Aucun commentaire:
Enregistrer un commentaire