Question

this is c plus plus the middletown wholesale copper wire company sells spools of copper wiring...

this is c plus plus

the middletown wholesale copper wire company sells spools of copper wiring for 100 each and ships them for 10 a piece. write a program that displays the status of an order.

it should use two functions in addition to function main().

the first function asks for the following date and stores the input values in reference parameters.

the number of spools ordered.

the number of spools in stock.

Any special shipping and handing charges.

the shipping and handling is normally 10 per school . if there are special charges, the program should ask the special charge per spool.

the second function receives the gathered date from the first function as arguments and the shiiping parameter has the default argument 10.00

the function displays on the backorder

the totall selling price of the portion ready to ship

total shipping and handling charges on the portion ready to ship

toal of the order ready to ship

input validation

not accept numbers less than 1 for spools ordered.

not accepted a number less than 0 for spools in stock or for shipping and handling charges

the number of ordered spools ready to ship from current stock

the number of ordered spools

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi There,

I have implented the requested functions and c++.

Please comment below if you need more information or any updates in the code..

Output:

Code:


#include <iostream>
using namespace std;

// read the input from console.
void readInputs(int& numberOfSpools, int& spoolsInStock, float& shippingAndHandling)
{
char c;
cout << "Please enter the number of spools ordered: ";
cin >> numberOfSpools;// read the number of spools
cout << "Please enter the number of spools in stock: ";
cin >> spoolsInStock;// read the number of spools in stock.
cout << "Are there any special shipping or handling charges (Y/N): ";
cin >> c; //read whether there are any special shipping and handling charges.
if(c == 'Y' || c == 'y')
{
cout << "Please Enter the special shipping and hadling charges: ";
cin >> shippingAndHandling; // read the special handling and shipping charges.
}
}

// calculate the value of the order
void calculateOrder(int orderedSpools, int spoolsInStock, float shippingAndHandling = 10.0)
{
// return by printing messages if the error coditions specfied in the problem statement occur.
if(orderedSpools < 1)
{
cout << "Invalid number of spools ordered. Exiting..." << endl;
return;
}
if(spoolsInStock < 0)
{
cout << "Invalid number of spools in stock. Exiting..." << endl;
return;
}
if(shippingAndHandling < 0)
{
cout << "Invalid shipping and handling charges. Exiting..." << endl;
return;
}
int spools = orderedSpools;
if(orderedSpools > spoolsInStock)
{
// uncomment this line and comment the below line in case if you need to consider only the number of in stock
// if ordered spools are greater than number of spools in stock.
//spools = spoolsInStock;
cout << "Not enough spools in stock to serve this request. Exiting..." << endl;
return;
}
// calculate the values for the spools and
  
cout << "Total Selling price = " << (spools) * 100 << endl;
cout << "Total Shipping Cost = " << (float)(spools) * shippingAndHandling << endl;
cout << "Total Order Cost = " << ((spools) * 100) + ((float)(spools) * shippingAndHandling) << endl;
}


int main()
{
int orderedSpools, spoolsInStock;
float shippingAndHandling = 10.0;
readInputs(orderedSpools, spoolsInStock, shippingAndHandling);
calculateOrder(orderedSpools, spoolsInStock, shippingAndHandling);
  
return 0;
}

Add a comment
Know the answer?
Add Answer to:
this is c plus plus the middletown wholesale copper wire company sells spools of copper wiring...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1 Normal 1 No Spac. Heading 1 Heading 2 TitleSubtitle Subtle Em... .Emphe 2 Title Styles...

    1 Normal 1 No Spac. Heading 1 Heading 2 TitleSubtitle Subtle Em... .Emphe 2 Title Styles Ch 6 Programming Challenge 14: Order Status lesale Copper Wire Company sells spools of copper wiring for $100 each. Write a program that displays the status of an order as in the example output below. The program should have a fanction that asks for the following data: The number of spools ordered - The number of spools in stock Whether there are special shipping...

  • The One Stop Fabric Shop sells 80 yards bolt of fabric for $100 each. Your job...

    The One Stop Fabric Shop sells 80 yards bolt of fabric for $100 each. Your job is to write a program that provides an invoice to a customer that will also include information on anything that might be back ordered. The program should have a function that asks for the following data: Customer information (include name, mailing address and phone number) The number of bolts ordered. The number of bolts in stock. Whether there are special shipping and handling charges....

  • Instructions for using the SAP ERP system start on page 13 of this document. Account Balances...

    Instructions for using the SAP ERP system start on page 13 of this document. Account Balances as of December 31, 2018 Debit Balance Credit Balance 100000 Bank Account $277,518 110100 Accounts Receivable (Direct Posting Account) 92,670 110150 Allowance for Bad Debts 2,500 200600 Inventory-Operating Supplies 8,832 200900 Inventory-Raw Materials (Direct Post) 52,000 200910 Inventory-Finished Goods (Direct Post) 281,298 200920 Inventory-Trading Goods (Direct Post) 66,474 210000 Prepaid Insurance 5,000 212000 Prepaid Advertising 1,100 220110 Land (Direct Post) 425,000 220210 Production Machinery,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT