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

ia Raptor you righ dick any componest ec Assignment Wnite a Raptor program that

ID: 3748933 • Letter: I

Question

ia Raptor you righ dick any componest ec Assignment Wnite a Raptor program that performs the following tasks All comment lines will be color-coded Ask the user for a number repr of an item and calculate and display the cost before application of discount, discount percentage, the actual amount of discount, and the final cost. The input must be in the order given above. The following table states the discount percentage based on quantity the quantity of a product sold, and the unit cost Quantity 1-19 50-99 100 or more 40% Check the input amount for the quantity and make sure the input value is not 0 or a negative number. If the input value is invalid, print the error message TNVALID Quantity" and do not perform any calculations. Once you have a vald input from the user, perform the computations.

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

int main()
{
ofstream outputFile;
string name;
int number;

//set format for dollar values
cout << fixed << showpoint << setprecision(2);
//Get user to open their file
do
{
cout << "To enter sales for Reid, enter R. "
<< "To enter sales for Jarid, enter J. "
<< "To enter sales for Nicole, enter N. "
<< "Enter your choice: ";
cin >> name;
// input validation for name
while (!(name == "R" || name == "J" || name == "N"))
{
cout << "Enter the first letter of your first name in caps: ";
cin >> name;
}

if (outputFile)
{
name += ".txt";
outputFile.open(name.c_str());
int sales;
double total = 0.0;

cout << "How many sales ammounts will you enter (Maximum is 4): ";
cin >> sales;
// input validation number of sales entered
if ((sales <= 0) || (sales >= 5))
{
cout << "Number is invalid may not be less than 1 or more "
<< "than 4. "
<< "Enter ammount of sales to be entered: ";
cin >> sales;
}
for (int count = 1; count <= sales; count++)
{
double ammount;
cout << "Enter the ammount for sale " << count << ": ";
cin >> ammount;
// Store total
total += ammount; //accumulate running total

double commission = total * .1;
outputFile << commission << endl;
outputFile << total << endl;

cout << "Commission earned for sales entered is: " << commission << endl;

// close file
outputFile.close();
}
}
cout << "Enter Z to quit or any key to go to menu: ";
cin >> name;
} while (name != "Z");


// display sales table

ifstream inputFile;

double total;
double commission;

inputFile.open("R.txt");

inputFile >> commission;
cout << "Total commission earned for Reid is: " << commission << endl;

inputFile.close();

inputFile.open("J.txt");
inputFile >> commission;
cout << "Total commission earned for Jarid is: " << commission << endl;
inputFile.close();

inputFile.open("N.txt");
inputFile >> commission;
cout << "Total commission earned for Nicole is: " << commission << endl;
inputFile.close();


system ("pause");
return 0;
}