c++ Homework

How do I use a prime read and sentinel value to control the repetition involved.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

float subsRate(float copyPrice, float subsCost, int issueNumber);
void displayMess(float perDiscount);
int magNumber = 0, averageAmount = 0, largestAmount = 0;

int main()
{
float copyPrice;
float subsCost;
int issueNumber;
float percentDiscount;

cout << "Enter Newsstand Price: $" ;
cin >> copyPrice ;

cout << "Enter Subscription Price: $" ;
cin >> subsCost ;

cout << "Enter Number of Issues in Subscription: " ;
cin >> issueNumber ;

percentDiscount = subsRate(copyPrice, subsCost, issueNumber);
displayMess(percentDiscount);

if (subsCost > copyPrice)
cout << "Warning!: Subscription Price needs to be smaller than the Newsstand" << endl;

}

float subsRate(float copyPrice, float subsCost, int issueNumber)
{
float perCopy;
float perDiscount;
float totalSubscriber;

perCopy = subsCost / issueNumber;
perDiscount = ((copyPrice - perCopy)/copyPrice * 100);
totalSubscriber = ((copyPrice - perCopy) * issueNumber);

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

cout << "Cost Per Issue at the Subscription Rate: $" << perCopy << endl;

cout << "Percent Discount: " << perDiscount << "%" << endl;
cout << fixed << showpoint << setprecision(2);
averageAmount = (perDiscount); //Make Person discount / Mag number for avg
cout << "Discount Average = " << averageAmount <<endl;

cout << "Total Amount Saved: $" << totalSubscriber << endl;


return perDiscount;
}

void displayMess(float perDiscount)

{
if (perDiscount > 75)
cout << "Bargain of the week!" << endl;
else if (perDiscount < 75 && perDiscount >= 50)
cout << "Great Deal!" << endl;
else if (perDiscount < 50 && perDiscount >= 25)
cout << "Special Offer!" << endl;
else
cout << "Thanks for your purchase!" << endl;

}
Adding to my comment at the top
I have to use an input of -9.99 for the single copy price to signify the end of data.
Topic archived. No new replies allowed.