Order Status, Can't figure out what is wrong with code.

I Need help on the following. I am almost done, but can't quite figure out what is wrong with my code. Here is what has to be done, so you can understand what I am trying to do:

Write a program that displays the status of an order. The program should have a function that asks for the following data:

1. The number of spools ordered
2. The number of spools in stock
3. If there are special shipping and handling charges
(Shipping and handling is normally $10 per spool) If there are special charges, it should ask for special charges per spool.

The gathered data should be passed as arguments to another function that displays:

1. The number of spools ready to ship from current stock.
2. The number of spools on backorder (if the number ordered is greater than what is in stock)
3. Subtotal of the portion ready to ship (the number of spools ready to ship times $100)
4. Total shipping and handling charges on the portion ready to ship
5. Total of the order ready to ship

The shipping and handling parameter in the second function should have the default arguments 10.00.

Input validation:

1. Do not accept numbers less than 1 for spools ordered
2. Do not accept number less than 0 for spools in stock or shipping and handling charges.


Here is my code:
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
  #include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;


void getData(double, double, double);
void displayInfo(double, double, double);



int main(double spoolsOrdered,double spoolsStocked, double charges, double TOTAL, double backOrdered, double spools)
{

cout << fixed << setprecision(2) << endl;

getData(spoolsOrdered, spoolsStocked, charges);

displayInfo(spools, backOrdered, TOTAL);




system("pause.exe");

return 0;
}//end int main


void getData(double spoolsOrdered, double spoolsStocked, double charges)
{

    char specialChargeYN;
    
    //get spools ordered
    cout << "How many spools ordered? ";
    cin >> spoolsOrdered;
    while (spoolsOrdered < 1)
    {
        cout << "You must enter at least 1 spool, please enter spools ordered: ";
        cin >> spoolsOrdered;
        
    }
    
    //get spools in stock
    cout << "How many spools in stock? ";
    cin >> spoolsStocked;
    while (spoolsStocked < 0)
        {
            cout << "Please enter a positive number for spools in stock: ";
            cin >> spoolsStocked;
        }//end while
        
        
    
    //are there special S&H charges?
    cout << "Are there any special shipping and handling charges?(Y/N) ";
    cin >> specialChargeYN;
    
    

		//get S&H charges
    if ( specialChargeYN == 'Y' || specialChargeYN == 'y')
	{
		cout << "What are the special charges per spool? ";
        cin >> charges;
	}
		else 

		charges = 10;

	
       
		while (charges < 0)
        {
            cout << "Please enter a positive number for S&H charges: ";
            cin >> charges;
		}//end while (charges)
        
}//end voidGetdata

void displayInfo(double spoolsOrdered, double spoolsStocked, double charges)
{

    double backOrdered;
    double subTotal;
    double totalSH;
    double TOTAL;
    double spools = spoolsStocked - spoolsOrdered;

    //Spools ready to ship from stock
    cout << "There are " << spools << " spools ready to be shipped. " << endl;
    
    // if spools ordered is more than spools stocked...
    if (spoolsOrdered > spoolsStocked)
    {
        //Backorder
        backOrdered = spoolsOrdered - spoolsStocked;
        cout << "There are " << backOrdered << " spools backordered." << endl;
               
		//Subtotal of spools
        subTotal = spoolsOrdered * 100;
        cout << "Subtotal: $" << subTotal << endl;
        
        //S&H charges
        totalSH = spoolsOrdered * charges;
        cout << "S & H Total: $" << totalSH << endl;
     }
    else
    {
        //Backorder
        cout << "There are no spools backordered." << endl;
        
        //Subtotal of spools
        subTotal = spoolsOrdered * 100;
        cout << "Subtotal: $" << subTotal << endl;
        
        //S&H charges
        totalSH = spoolsOrdered * charges;
        cout << "S & H Total: $" << totalSH << endl;
    }

    
    //Order Total
    TOTAL = totalSH + subTotal;
    cout << "The total of the order ready to ship is: $" << TOTAL << endl;


}//end void displayInfo 
Last edited on
Topic archived. No new replies allowed.