Question

In: Computer Science

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 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

#include <iostream>

using namespace std;

void takeInput(int &spoolsOrdered, int &spoolsInStock, int &shippingAndHandlingCharges) {
do {
cout<<"Enter number of spools ordered: ";
cin>>spoolsOrdered;
} while(spoolsOrdered < 1);
do {
cout<<"Enter number of spools in stock: ";
cin>>spoolsInStock;
} while(spoolsInStock < 0);
do {
cout<<"Enter special shipping and haddling charges: ";
cin>>shippingAndHandlingCharges;
} while(shippingAndHandlingCharges < 0);
}

void displayInformation(int spoolsOrdered, int spoolsInStock, int shippingAndHandlingCharges=10) {
int spoolsReadyToShip = spoolsOrdered;
int spoolsOnBackOrder = 0;
if (spoolsOrdered > spoolsInStock) {
spoolsReadyToShip = spoolsInStock;
spoolsOnBackOrder = spoolsOrdered - spoolsInStock;
}
int totalSalesPrice = spoolsReadyToShip * 100;
int totalShippingAndHandlingCharges = shippingAndHandlingCharges * spoolsReadyToShip;
int totalPrice = totalSalesPrice + totalShippingAndHandlingCharges;
cout<<"Spools ready to ship: "<<spoolsReadyToShip<<endl;
cout<<"Spools on backorder: "<<spoolsOnBackOrder<<endl;
cout<<"Total sales price: $"<<totalSalesPrice<<endl;
cout<<"Total shipping and handling charges: $"<<totalShippingAndHandlingCharges<<endl;
cout<<"Total price: $"<<totalPrice<<endl;
}

int main()
{
int spoolsOrdered, spoolsInStock, shippingAndHandlingCharges;
takeInput(spoolsOrdered, spoolsInStock, shippingAndHandlingCharges);
shippingAndHandlingCharges+=10;
displayInformation(spoolsOrdered, spoolsInStock, shippingAndHandlingCharges);
return 0;
}


Related Solutions

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...
*****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...
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...
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...
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.
Program must be in C++! Write a program which: Write a program which uses the following...
Program must be in C++! Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to...
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
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!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT