1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
using namespace std;
//Prompt user for their name
//Prompt user for their address
//Prompt user for their zip code
//Prompt user for their city
//Prompt user for their state
//Prompt user for their number of doflingies ordered
void information (string a, string b, string c, string d, string e);
void shippingInfo(string a, string b, string c, string d, string e, int i, int j, int k);
void shippingReciept();
int main()
{
string name, address, zipcode, city, state = "";
int numOfDoflingies = 0; //Set the original number to 0 until input
int huge; //num of huge containers
int large; //num of large containers
int medium; //num of medium containers
int small = 0; //num of small containers
double tax; //the current tax rate
double hugeS; //variable that represents the price of shipping per huge container
double largeS; //variable that represents the price of shipping per large container
double mediumS; //variable that represents the price of shipping per medium container
double smallS; //variable that represents the price of shipping per small container
double num; //based on number of doflingies this number will represent the price per doflingie
double extraTax; //variable that represents the sales price factoring sales tax
int repeatProgram = 0;
int Selection = 0;
{
information (name, address, city, state, zipcode);
cout << "How many doflingies are you ordering? " << endl;
//Prompts user how many doflingies are ordered
cin >> numOfDoflingies;
{
if (numOfDoflingies >= 10 && numOfDoflingies < 1000)
{
cout << " Please type in the sales tax ";
//Prompts user to enter the sales tax and store that as the value for tax
cin >> tax;
if(numOfDoflingies >= 10 && numOfDoflingies < 1000)
//If the num of Doflingies is less then 500..
{
huge = (numOfDoflingies/50);
//formula for finding out the number of huge containers needed for the doflingies ordered
if (huge < 1)
{
huge = 0;
//If huge is less then 1 huge is 0
hugeS = (huge * 4);
//Price of shipping would be huge times the price per huge container.
}
else if (huge >= 1)
{
huge = huge;
//If huge is greater than or equal to 1, huge is equal to that number
hugeS = (huge * 4);
//Price of shipping would be huge times the price per huge container.
}
large = ((numOfDoflingies-(huge*50))/20);
//formula for finding out the number of large containers needed for the doflingies ordered
//take the number of doflingies and subtract the number of doflingies in the huge container
//divide by 20 to find out how many full large containers customer needs.
if(large < 1)
{
large = 0;
//If huge is less then 1 huge is 0
largeS = (large * 2);
//number of large containers times the shipping price of large containers
}
else if (large >= 1)
{
large = large;
//If large is greater than 1, large is large
largeS = (large * 2);
//Shipping is the num of large containers times 2 (shipping price)
}
medium = ((numOfDoflingies-(huge*50))-(large*20))/5;
//the formula for medium is the num of doflingies - huge containers * 50 - large containers * 20
//divided by 5 to find number of containers left
if (medium < 1)
{
medium = 0;
//if medium is less than 1 medium is 0
mediumS = (medium * .75);
//number of medium containers times the shipping price of medium containers(.75)
}
else if (medium >= 1)
{
medium = medium;
//if medium is more than or equal than 1 then medium is medium
mediumS = (medium * .75);
//number of medium containers times the shipping price of medium containers(.75)
}
small = ((numOfDoflingies-(huge*50))-(large*20))-(medium*5)/1;
//Formula for finding out the number of small containers needed for the remaining numOfDoflingies
if (small < 1)
{
small = 0;
//if small is less than 1 then
smallS = (small * .2);
//the number of small containers times the shipping price (.2)
}
else if (small >= 1)
{
small = small;
//if small is less than 1 then
smallS = (small * .2);
//the number of small containers times the shipping price (.2)
}
int totalCont = (huge+small+medium+large); //Formula for the total amount of containers needed
double shipPrice = (hugeS+smallS+mediumS+largeS); //Formula for the total price of the shipping
if (numOfDoflingies >= 500)
{
num = 15.95;
//If the number of doflingies ordered is greater than or equal to 500
//num(price per doflingie) is equal to 15.95
}
if (numOfDoflingies >= 250 && numOfDoflingies < 500)
{
num = 17.50;
//If the number of doflingies ordered is greater than or equal to 250 and less than 500
//num(price per doflingie) is equal to 17.50
}
if (numOfDoflingies >= 100 && numOfDoflingies < 250)
{
num = 18.95;
//If the number of doflingies ordered is greater than or equal to 100 and less than 250
//num(price per doflingie) is equal to 18.95
}
if (numOfDoflingies < 100)
{
num = 19.95;
//If the number of doflingies ordered is less than 100 num(price per doflingie) is 19.95
}
double extraTax= (numOfDoflingies*num*(tax/100));
//formula that represents number of doflingers times initial price times the tax
double salesPrice = (numOfDoflingies*num+extraTax);
//formula that adds the sales price of the doflingies times the tax from the doflingies
double endTotal = (shipPrice)+(salesPrice);
//formula that calculates end total price including price, tax, and shipping price of the doflingies
cout << "Please select whether you want to see" << endl << "the Shipping information [1] " << " or the Dofliniges receipt [2] " << endl;
cin >> Selection;
if (Selection == 1)
{
do
{
shippingInfo (name, address, city, state, zipcode, numOfDoflingies, repeatProgram, Selection);
}
while (repeatProgram == 0);
}
if (Selection == 2)
{
do
{
cout << "Container Size Number Required Shipping Price Price+Tax Total Price" << endl;
cout << "--------------- --------------- -------------- --------- ---------" << endl;
cout <<"Huge" << " "<< huge << " "<< hugeS << endl;
cout <<"Large" << " "<< large << " "<< largeS << endl;
cout <<"Medium" << " "<< medium << " "<< mediumS << endl;
cout <<"Small" << " "<< small << " "<< smallS << endl;
cout <<"Total" << " "<< totalCont << " "<< shipPrice << " " << salesPrice << " " <<endTotal << endl << endl ;
cout << "Would you like to print another copy? Please enter 0 for yes or 1 for no" << endl;
cin >> Selection;
}
while (repeatProgram == 0);
}
else if (Selection != 1 || Selection != 2)
{
cout << "Invalid menu option please select 1 or 2" << endl;
}
}
else if (numOfDoflingies < 10 || numOfDoflingies > 1000)
{
cout << "Invalid number of doflingies ordered. Please restart program" << endl;
}
}
}
}
};
void information (string a, string b, string c, string d, string e)
{
cout << " Enter the name of the purchaser: "; //Prompts user for their name
getline (cin, a);
cout << " Enter street address: "; //Prompts user for their street address
getline (cin, b);
cout << " Enter city: "; // Prompts user their city
getline (cin, c);
cout << " Enter state: ";
//Prompts user for their state
getline (cin, d);
cout << " Enter zipcode: ";
//Prompts user for their zipcode
getline (cin, e);
}
void shippingInfo(string a, string b, string c, string d, string e, int i, int j, int k)
{
cout << "Ship To: " << a << endl;
cout << " " << b << endl;
cout << " " << c << ", " << d << ", " << e << endl;
cout << "" << endl;
cout << "No. Doflingies: " << i << endl;
cout << endl;
cout << "Would you like to print another copy? Please enter 0 for yes or 1 for no" << endl;
cin >> j;
}
|