// Cassandr Hamric
//Midterm Project
// This program calculates the cost of a dog license depending on the size, if the dog is fixed, and the weight category of the dog.
#include <iostream>
#include <string>
#include <iomanip>
usingnamespace std;
int main()
{
int y=0, Y=0, n=0, N=0, years, cost, total;
float weight;
string name, size;
char fixed, county;
cout<<" Dog License Renewal" <<endl;
cout<<" County A" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<left;
cout <<setw(20)<<"Size (Pounds)" <<setw(10)<<"Fixed"
<<setw(10)<<"Not Fixed" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<setw(20) << "Small 0-15" <<setw(10) <<"$50" <<setw(10) <<"$75" <<setw(10) <<endl;
cout<<setw(20) << "Medium 16-45" <<setw(10) <<"$100" <<setw(10) <<"$150" <<setw(10) <<"Prices Per Year" <<endl; // Dog Pricing table per weight and if fixed
cout<<setw(20) << "Large 46+" <<setw(10) <<"$150" <<setw(10) <<"$200" <<setw(10) <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout<<" Dog License Renewal" <<endl;
cout<<" County B" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<left;
cout <<setw(20)<<"Size (Pounds)" <<setw(10)<<"Fixed"
<<setw(10)<<"Not Fixed" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<setw(20) << "Small 0-15" <<setw(10) <<"$60" <<setw(10) <<"$85" <<setw(10) <<endl;
cout<<setw(20) << "Medium 16-45" <<setw(10) <<"$110" <<setw(10) <<"$160" <<setw(10) <<"Prices Per Year" <<endl; // Dog Pricing table per weight and if fixed
cout<<setw(20) << "Large 46+" <<setw(10) <<"$160" <<setw(10) <<"$210" <<setw(10) <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout << endl;
cout <<"Do you reside in County A or B? Enter A or B: ";
cin >> county;
if (county != 'A' && county != 'a' && county != 'B' && county != 'b') // Validate input allowing only AaBb answers
{
cout <<"Invalid entry. Please restart program & Enter A or B " <<endl; //If invalid entry, display error message
system("pause");
return 0;
}
cout<<endl;
cout <<"Is your dog spayed/neutered? Y/N ";
cin >>fixed;
if (fixed != 'Y' && fixed != 'y' && fixed != 'N' && fixed != 'n') // Validate input allowing only YyNn answers
{
cout <<"Invalid entry. Please restart program & Enter Y or N " <<endl; //If invalid entry, display error message
system("pause");
return 0;
}
cout<<endl;
cout <<"Enter your dog's weight in pounds "; //Get Dogs Weight
cin >>weight;
{
if ( fixed == 'Y' || fixed == 'y' && county =='A' || county =='a' ) // Assign cost to weight categories in which dogs are fixed and belong to County A.
{
if (weight <= 15){
cout <<"Your dog is considered small" <<endl;
cost =50 ;}
elseif (weight <=45){
cout <<"Your dog is considered medium" <<endl;
cost = 100 ;}
elseif (weight >=46) {
cout <<"Your dog is considered large"<<endl;
cost = 150 ;}
}
if ( fixed == 'N' || fixed == 'n' && county =='A' || county =='a' ) // Assign cost to weight categories in which dogs are not fixed and County is A.
{
if (weight <=15){
cout <<"Your dog is considered small" <<endl;
cost = 75;}
elseif (weight <=45){
cout <<"Your dog is considered medium" <<endl;
cost = 150;}
elseif (weight >=46){
cout <<"Your dog is considered large" <<endl;
cost = 200;}
}
}
{
if (fixed == 'Y' || fixed == 'y' && county == 'B' || county == 'b') // Assign cost to weight categories in which dogs are fixed and belong to County B.
{
if (weight <= 15){
cout <<"Your dog is considered small" <<endl;
cost =60 ;}
elseif (weight <=45){
cout <<"Your dog is considered medium" <<endl;
cost = 110 ;}
elseif (weight >=46) {
cout <<"Your dog is considered large"<<endl;
cost = 160 ;}
}
if ( fixed == 'N' || fixed == 'n' && county == 'B' || county == 'b' ) // Assign cost to weight categories in which dogs are not fixed and County is B.
{
if (weight <=15){
cout <<"Your dog is considered small" <<endl;
cost = 85;}
elseif (weight <=45){
cout <<"Your dog is considered medium" <<endl;
cost = 160;}
elseif (weight >=46){
cout <<"Your dog is considered large" <<endl;
cost = 210;}
}
}
cout <<endl;
cout <<"How many years would you like your license for? (7 year Max) "; //Get years license good for
cin >> years;
//Validate year input is no bigger than 7
if ( years >= 8)
{
cout << "That is not a selection of 1-7, run the program again and enter a value of 1-7." <<endl; //If year input is bigger than 7, output error message
system ("pause");
return 0;
}
total = cost * years; // Math operation calculating total of dog license renewal
cout <<endl;
cout <<"What is your Dog's Name? "; //Get dogs name
cin >> name;
cout<<endl;
cout <<name <<"'s License renewed for " <<years <<" year(s) in County" <<county <<" will cost $" <<total <<endl; //Output total cost of license for x amount of years
system("pause");
return 0;
}
<code>
// Cassandr Hamric
//Midterm Project
// This program calculates the cost of a dog license depending on the size, if the dog is fixed, and the weight category of the dog.
using namespace std;
int main()
{
int y=0, Y=0, n=0, N=0, years, cost, total;
float weight;
string name, size;
char fixed, county;
cout<<" Dog License Renewal" <<endl;
cout<<" County A" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<left;
cout <<setw(20)<<"Size (Pounds)" <<setw(10)<<"Fixed"
<<setw(10)<<"Not Fixed" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<setw(20) << "Small 0-15" <<setw(10) <<"$50" <<setw(10) <<"$75" <<setw(10) <<endl;
cout<<setw(20) << "Medium 16-45" <<setw(10) <<"$100" <<setw(10) <<"$150" <<setw(10) <<"Prices Per Year" <<endl; // Dog Pricing table per weight and if fixed
cout<<setw(20) << "Large 46+" <<setw(10) <<"$150" <<setw(10) <<"$200" <<setw(10) <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout<<" Dog License Renewal" <<endl;
cout<<" County B" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<left;
cout <<setw(20)<<"Size (Pounds)" <<setw(10)<<"Fixed"
<<setw(10)<<"Not Fixed" <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout <<setw(20) << "Small 0-15" <<setw(10) <<"$60" <<setw(10) <<"$85" <<setw(10) <<endl;
cout<<setw(20) << "Medium 16-45" <<setw(10) <<"$110" <<setw(10) <<"$160" <<setw(10) <<"Prices Per Year" <<endl; // Dog Pricing table per weight and if fixed
cout<<setw(20) << "Large 46+" <<setw(10) <<"$160" <<setw(10) <<"$210" <<setw(10) <<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout << endl;
cout <<"Do you reside in County A or B? Enter A or B: ";
cin >> county;
if (county != 'A' && county != 'a' && county != 'B' && county != 'b') // Validate input allowing only AaBb answers
{
cout <<"Invalid entry. Please restart program & Enter A or B " <<endl; //If invalid entry, display error message
system("pause");
return 0;
}
cout<<endl;
cout <<"Is your dog spayed/neutered? Y/N ";
cin >>fixed;
if (fixed != 'Y' && fixed != 'y' && fixed != 'N' && fixed != 'n') // Validate input allowing only YyNn answers
{
cout <<"Invalid entry. Please restart program & Enter Y or N " <<endl; //If invalid entry, display error message
system("pause");
return 0;
}
cout<<endl;
cout <<"Enter your dog's weight in pounds "; //Get Dogs Weight
cin >>weight;
if (weight <=15){
cout <<"Your dog is considered small" <<endl;}
else if (weight <=45){
cout <<"Your dog is considered medium" <<endl;} //Inform user the weight category in which their dog is in.
else if (weight >=46){
cout <<"Your dog is considered large" <<endl; }
{
if ( fixed == 'Y' || fixed == 'y' && county =='A' || county =='a' ) // Assign cost to weight categories in which dogs are fixed and belong to County A.
{
if (weight <= 15){
cost =50 ;}
else if (weight <=45){
cost = 100 ;}
else if (weight >=46) {
cost = 150 ;}
}
if ( fixed == 'N' || fixed == 'n' && county =='A' || county =='a' ) // Assign cost to weight categories in which dogs are not fixed and County is A.
{
if (weight <=15){
cost = 75;}
else if (weight <=45){
cost = 150;}
else if (weight >=46){
cost = 200;}
}
}
{
if (fixed == 'Y' || fixed == 'y' && county == 'B' || county == 'b') // Assign cost to weight categories in which dogs are fixed and belong to County B.
{
if (weight <= 15){
cost =60 ;}
else if (weight <=45){
cost = 110 ;}
else if (weight >=46) {
cost = 160 ;}
}
if ( fixed == 'N' || fixed == 'n' && county == 'B' || county == 'b' ) // Assign cost to weight categories in which dogs are not fixed and County is B.
{
if (weight <=15){
cost = 85;}
else if (weight <=45){
cost = 160;}
else if (weight >=46){
cost = 210;}
}
}
cout <<endl;
cout <<"How many years would you like your license for? (7 year Max) "; //Get years license good for
cin >> years;
//Validate year input is no bigger than 7
if ( years >= 8)
{
cout << "That is not a selection of 1-7, run the program again and enter a value of 1-7." <<endl; //If year input is bigger than 7, output error message
system ("pause");
return 0;
}
total = cost * years; // Math operation calculating total of dog license renewal
cout <<endl;
cout <<"What is your Dog's Name? "; //Get dogs name
cin >> name;
cout<<endl;
cout <<name <<"'s License renewed for " <<years <<" year(s) in County" <<county <<" will cost $" <<total <<endl; //Output total cost of license for x amount of years