Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

pay attention to program requirements c++ last 2 are the output Paragraph Styles

ID: 3725046 • Letter: P

Question

pay attention to program requirements
c++
last 2 are the output

Paragraph Styles The ACME Ethernet Cable Company sells spools of 1000 feet of Cat6 Ethernet cable for $154.50 each. e company keeps track of the number of spools it has in stock in the file inStock.txt and the number it has on backorder in the file backorder.txt. Each file contains a single integer. Write a modular program, spFunctionsHWspools.cpp, that accepts an order and creates an invoice for the order The program should ask for the following data: The number of spools ordered. Input Validation: Do not accept numbers less than 1 for spools ordered Whether there are special shipping and handling charges If there are special charges, the program should ask for the special charges per spool. Otherwise, shipping and handling is normally $15 per spool Input Validation: Do not accept a number less than 0 for shipping and handling charges. . . State of residence The file state Tax.txt contains a list of states (using a state's two letter abbreviation) to keep track of whether the company must collect taxes or not. If an order ships to a state indicated in the file, the company must collect the amount of tax indicated by the percentage rate in the file. Each line of the file contains a two letter abbreviation for a state followed by a space and then a percentage (including the s sign). An example of what state Tax.txt might contain: . AR 9.38% CA 8.25% ID 6.03% SC 7.22% TX 8.19% State tax is to be applied to product cost only; it should not be applied to shipping and handling charges. If the state abbreviation entered by the user is not in the file, no state tax applies. .

Explanation / Answer

here is your program : ---------------->>>>>>>>>>

#include<iostream>
#include<fstream>
#include<sstream>

using namespace std;

int getBackorderCount(){
ifstream ifs;
ifs.open("backorder.txt");
int n;
if(ifs.is_open()){
  ifs>>n;
  ifs.close();
}else{
  ifs.close();
  exit(0);
}

return n;
}

int getSpoolsOrdered(){
int n = -1;
while(n < 1){
  cout<<" How many Spools would you like to purchase? ";
  cin>>n;
  if(n >= 1){
   break;
  }
  cout<<" Invalid Data. number of spools must be positive .";
}

return n;
}

double getStateTaxRate(){
string st;
st.reserve(3);
cout<<" Please enter the two character state abbreviation of the shipping address? ";
cin>>st;
string rate;
stringstream ss;
rate.reserve(6);
ifstream ifs;
ifs.open("stateTax.txt");
if(ifs.is_open()){
  string stf;
  stf.reserve(2);
  ifs>>stf;
  double r;
  while(!ifs.eof()){
   if(stf == st){
    ifs>>rate;
    ss<<rate[0]<<rate[1]<<rate[2]<<rate[3];
    ss<<" ";
    ss>>r;
    ifs.close();
    return r*(0.01);
   }
   ifs>>rate;
   ifs>>stf;
  }
  ifs.close();
  return 0;
}else{
  return -1;
}
}

double determineShippingCharges(){
char ch;
cout<<" The default shipping and handling charges is $15 per spool";
while(true){
  cout<<" Are there special shipping and handling charge for this order? (y/n)";
  cin>>ch;
  if(ch == 'y' || ch == 'Y' || ch == 'n' || ch == 'N'){
   break;
  }
  cout<<" That is invalid response. please respond y or n.";
}
if(ch == 'y' || ch == 'Y'){
  double d;
  while(true){
   cout<<" What is the special shipping and handling charge for this order?";
   cin>>d;
   if(d >= 0){
    break;
   }
   
   cout<<" Invalid Data. Shipping and handling charge must be positive.";
  }
  return d;
}else{
  return 15;
}
}

int getStockCount(){
ifstream ifs;
ifs.open("inStock.txt");
int n;
if(ifs.is_open()){
  ifs>>n;
  ifs.close();
}else{
  ifs.close();
  exit(0);
}

return n;
}
void setBackorderCount(int backorder){
ofstream ofs;
ofs.open("backorder.txt");
if(ofs.is_open()){
  ofs<<backorder;
  ofs.close();
}else{
  ofs.close();
  exit(0);
}
}
void setInstockCount(int inst){
if(inst < 0){
  return;
}
ofstream ofs;
ofs.open("inStock.txt");
if(ofs.is_open()){
  ofs<<inst;
  ofs.close();
}else{
  exit(0);
}
}


void createInvoice(int spoolsOrdered,double shippingCharge){
int inst = getStockCount();
int ship;
double rate = getStateTaxRate();
if(rate == -1){
  rate = 0;
  cout<<" State Stock File Opening error ";
}
if(spoolsOrdered > inst){
  cout<<" "<<(spoolsOrdered-inst)<<" spools will be backordered and shipped as soon as posible";
  ship = inst;
  setBackorderCount(spoolsOrdered-inst);
}else{
  cout<<" You requested "<<spoolsOrdered<<" spools.";
  ship = spoolsOrdered;
}
setInstockCount(inst-ship);
cout<<" We are shipping "<<inst<<" spools";
cout<<"                                The Acme Ethernet Cable Company ";
cout<<"                         Quantity     cost per spool      cost ";
cout<<"                            "<<ship<<"         154.50"<<"              "<<(ship*154.50);
cout<<" SubTotal                                                  "<<(ship*154.50);
cout<<" Shipping/Handling                        "<<shippingCharge<<"               "<<(ship*shippingCharge);
cout<<" SalesTax                                                  "<<(rate*(ship*154.50));
cout<<" Total                                                     "<<(ship*154.50 + ship*shippingCharge + rate*(ship*154.50));
}

int main(){
cout<<" Welcome to The ACME Ethernet Cable Company.";
cout<<" We sell spools of 1000 ft Cat6 Ethernet Cable for $154.50 each ";
int numSpool = getSpoolsOrdered();
double ship = determineShippingCharges();
createInvoice(numSpool,ship);
return 0;
}