Question

In: Computer Science

c++ A program that displays the status of an order. a) Program uses 2 functions (in...

c++

A program that displays the status of an order.
a) Program uses 2 functions (in addition to main ()).
b) The first function asks the user for the data below and stores the input values in reference parameters.
c) Input data from user: # of spools ordered, # of spools in stock, any special shipping & handling charges over and above the $10 rate.
d) The second function receives as arguments any values needed to compute and display the following information:
e) # of spools ready to ship from current stock, # of ordered spools on backorder (if ordered > in stock),
f) Total sales price of portion ready to ship (# of spools ready to ship X $100),
g) Total shipping and handling charges on the portion ready to ship, Total of the order ready to ship.
h) Shipping & handling parameter in 2nd function should have a default argument of $10.00.
I) Input validation: Do not accept numbers < 1 for spools ordered,
J) Input validation: Do not accept numbers < 0 for spools in stock or for shipping & handling charges.

Solutions

Expert Solution

Code:

#include<iostream>
using namespace std;
void fun1(int &spools_ordered, int &spools_stock, int &special_charges)//function 1
{
   while(1)
   {
       cout << "# of spools ordered: ";cin>>spools_ordered;
       if(spools_ordered < 1)//input validation
       {
           cout << "Enter proper input" <<endl;
       }
       else break;
   }
   while(1)
   {
       cout << "# of spools in stock: ";cin>>spools_stock;
       if( spools_stock < 0)//input validation
       {
           cout << "Enter proper input" <<endl;
       }
       else break;
   }
   while(1)
   {
       cout << "special shipping & handling charges over and above the $10 rate: ";cin>>special_charges;
       if( special_charges < 0)//input validation
       {
           cout << "Enter proper input" <<endl;
       }
       else break;
   }
}
void fun2(int &spools_stock, int &spools_ordered, int &spools_ready, int &spools_backorder, int &sales_ready, int &total_ready, int &total_shipping, int shipping_charges=10)//function2 with default argument
{
   spools_ready = spools_stock;//since no of spools ready to be shipped are those which are in the stock
   spools_backorder = (spools_ordered > spools_stock ? spools_ordered - spools_stock : 0);//if there is enough stock, backdoor is 0 otherwise, it is the difference of spools ordered to those in stock
   sales_ready = spools_ready * 100;//sales is spools * 100
   total_shipping = spools_ready * shipping_charges;//product of no of spools and their shipping charges
   total_ready = sales_ready + total_shipping;//total is sales + shipping for all the spools
}
int main()
{
   int spools_ordered, spools_stock, special_charges, spools_ready, spools_backorder, sales_ready, shipping_charges, total_ready, total_shipping;
   fun1(spools_ordered, spools_stock, special_charges);
   fun2(spools_stock, spools_ordered, spools_ready, spools_backorder, sales_ready, total_ready, total_shipping, special_charges);
   cout << "# of spools ordered: " << spools_ordered << endl;
   cout << "# of spools in stock: " << spools_stock << endl;
   cout << "# of spools ready to ship from current stock: " << spools_ready << endl;
   cout << "# of ordered spools on backorder: " << spools_backorder << endl;
   cout << "Total sales price of portion ready to ship: " << sales_ready << endl;
   cout << "Total shipping and handling charges on the portion ready to ship: " << total_shipping << endl;
   cout << "Total of the order ready to ship: " << total_ready << endl;
   return 0;
}

Output:


Related Solutions

c++ Write a program that displays the status of an order. a) Program uses 2 functions...
c++ Write a program that displays the status of an order. a) Program uses 2 functions (in addition to main ()). b) The first function asks the user for the data below and stores the input values in reference parameters. c) Input data from user: # of spools ordered, # of spools in stock, any special shipping & handling charges over and above the $10 rate. d) The second function receives as arguments any values needed to compute and display...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice (known as the come-out roll) is equal to 7...
In C# A Tic Tac Toe program that uses functions and arrays. The program should start...
In C# A Tic Tac Toe program that uses functions and arrays. The program should start by asking the player one for their name and then player two for their name. Then should print the board and ask the user what column and then what row they would like to put their x (or o, depending on the player) . Use the clear function to make it look as though the board is never repeating.. Thanks!
In C++ prototype functions above "main" and define them below "main"; Write a program that uses...
In C++ prototype functions above "main" and define them below "main"; Write a program that uses two identical arrays of at least 20 integers. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should keep count of the number of exchanges it makes. The program then should call a function that uses the selection sort algorithm to sort the other arrays. It should also keep count of...
In C, create a program that displays the minimum and maximum values stored in a data...
In C, create a program that displays the minimum and maximum values stored in a data file "datafile.txt". Use the following function prototype:  void minmaxarray(float value, float *min, float *max);
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
C++ Overloaded Hospital Write a program that computes and displays the charges for a patient’s hospital...
C++ Overloaded Hospital Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. Please keep asking the user until the user enters the valid choice. Please refer to the test cases for more details. If the patient was an in-patient the following data should be entered: • The number of days spent in the hospital • The daily rate •...
Write a program in C++ that asks the user for his/her Taxable Income and displays the...
Write a program in C++ that asks the user for his/her Taxable Income and displays the Income Tax owed. Use the following table to calculate the Income Tax: Taxable Income Tax Rate $0 to $9,225 / 10% $9,226 to $37,450 / $922.50 plus 15% of the amount over $9,225 $37,451 to $90,750 / $5,156.25 plus 25% of the amount over $37,450 $90,751 to $189,300 / $18,481.25 plus 28% of the amount over $90,750 $189,301 to $411,500 / $46,075.25 plus 33%...
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by...
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by sum of the digits in them. For example, 2924 is divisible by (2+9+2+4 = 17). Your program should display all these possible numbers in the given range, and each number should be separated from the other by a space.
Complete Question 1a-c 1a) Write a C program that displays all the command line arguments that...
Complete Question 1a-c 1a) Write a C program that displays all the command line arguments that appear on the command line when the program is invoked. Use the file name cl.c for your c program. Test your program with cl hello goodbye and cl 1 2 3 4 5 6 7 8 and cl 1b) Write a C program that reads in a string from the keyboard. Use scanf with the conversion code %s. Recall that the 2nd arg in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT