1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
// 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>
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
system("pause");
return 0;
}
|