There are a number of things about the code which could be improved. but the main one for me is the hard-coding of numbers such as
in more than one place. This can be a real-world problem. What if the pricing changes? The programmer goes into the code, changes the price but it still uses the old value because it is scattered throughout the code and some were missed. Putting values like this in just a single place would be the primary problem to be fixed. (looking at some of the commented-out lines, it seems that idea was considered but not carried through).
Another issue is the use of type double for integer values. Where a value is clearly an integer - a whole number of cameras for example, then the variable should be an integer.
Use of floating-point can allow such nonsense as this:
Enter total number of NW-PCs being purchased: 3.14
Enter total number of Second Drives being purchased: 2.718
Enter total number of Cameras being purchased: 0.5
Enter total number of Software Bundles being purchased: 0.3333
123 Main St
Somewhere MO 65555
QTY Item Cost
3 NW-PC $ 4704.44
3 Second Drive $ 228.31
0 Camera $ 59.50
0 Software Bundle $ 16.33
Total $ 5008.59
Tax $ 383.16
Grand Total $ 5391.74
Enter any key to continue:
As for your teacher's concerns, I'm not sure, possibly it was a reference to line 57?
totalTax = (subTotal / 100) * 7.65;
My first concern on reading this line was whether integer division was taking place. At line 18, the variable
is declared. So the calculation will correctly do a floating-point division. But I suppose what your teacher was referring to was the use of
in the same expression. I would usually tend to write
and this is probably what your teacher wanted.