Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DIRECTIONS Follow the instructions for starting your C++ development tool. Depen

ID: 3817153 • Letter: D

Question

DIRECTIONS Follow the instructions for starting your C++ development tool. Depending on the development tool you are using, you may need to create a new project; if so, name the project Lab12-2 Project and save it in the Cpp8 Chap12 folder. Enter the instructions shown in Figure 12-17 in a source file named Lab12-2.cpp. (Do not enter the line numbers.) Save the file in either the project folder or the Cpp8 Chap12 folder. Now, follow the appropriate instructions for running the Lab12-2.cpp file. Test the program using the same data you used to desk-check the program. If necessary, correct any bugs (errors) in the program

Explanation / Answer

the user input is 75,200 it comes under the value 999999,so corresponding value is 0.hece the cost will b output as 0 and whe user enter -1 as the while loop codition becomes false as numOrdered <0 so program stops.

#include <iostream>
using namespace std;
int main()
{
int shippingCharges[3][2]={{50,20},{100,10},{999999,0}};
int numOrdered=0;
int rowSub=0;
cout<<"Number ordered is: ";
cin>>numOrdered;
while(numOrdered>0&&numOrdered<=999999){
rowSub=0;
while(rowSub<3&& numOrdered>shippingCharges[rowSub][0])
rowSub+=1;
cout<<"Shipping charge of a quatity of "<<numOrdered<<" is $"<<shippingCharges[rowSub][1]<<endl<<endl;
cout<<"Number ordered is: ";
cin>>numOrdered;
}
return 0;
}
  

Output:

Number ordered is: 75200   
Shipping charge of a quatity of 75200 is $0      
Number ordered is: -1