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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
#include <iostream>
using std::fixed;
using std::cout;
using std::cin;
using std::endl;
#include <iomanip>
using std::setprecision;
#include <stdlib.h>
int main ()
{
// 1: Declare Variables
const double PERCENT_PROFIT= .25;
const double STATE_TAX_RATE= .075;
const double COST_PER_SQUARE_FT= 66.67;
const double BEDROOM_SIZE= 360.0;
const double WOODEN_DECK= 2000.0;
const double DELUXE_CABINETS= 20000.0;
const double House_Square_Footage= 3000.0;
double optionalFeatures= 0.0;
double bedrooms= 0.0;
double deck= 0.0;
double cabinets= 0.0;
double netHomeCost= 0.0;
double basicHomeCost= 0.0;
double taxes= 0.0;
double profit= 0.0;
double discount= 0.0;
double totalHomeCost= 0.0;
char repeat = y;
// Welcome
cout<<"Welcome to our program. This will help you determine the cost of your house."<<endl;
do {
// 2: Cost Determination Input
int choice= 0;
cout << "For the Standard house option, please insert 1\nFor the house with additional features, please insert 2.\n";
cin >> choice;
if( choice !=1 && choice !=2 )
{
cout<<"Incorrect input detected \n";
exit (1); //This stops the program
}else if (choice ==2)
{ //custom made house
//2.1: How many extra bedrooms?
int bedrooms;
cout << "If you would like extra bedrooms, please input 1 or 2 based on how many you would like.\n";
cout << "If you have selected the standard house option or would not like any extra bedrooms, please insert 0.\n";
cin >> bedrooms;
//If bad input
if ( bedrooms !=0 && bedrooms !=1 && bedrooms !=2 )
{
cout<<"Incorrect input for extra bedroom\n";
exit(2);
} else {
//if good input
House_Square_Footage== House_Square_Footage + (bedrooms * BEDROOM_SIZE);
}
//2.2: Would you like a wooden deck?
int deck;
cout << "If you would like an additional $2000 wooden deck, please insert 1.\n";
cout << "If you have selected the standard house and would not like the deck, please insert 0.\n";
cin >> deck;
//if bad input
if ( deck !=1 && deck !=0 )
{
cout<<"Incorrect input regarding the additional deck\n";
exit (3);
} else {
//Correct input
optionalFeatures += deck * WOODEN_DECK;
}
//2.3: Counter Tops choice
int cabinets;
cout << "If you would like a deluxe set of counter tops which cost $20.000, please insert 1\n";
cout << "If you have selected the standard house or would not like a deluxe set, please insert 0\n";
cin >> cabinets;
//If bad input
if ( cabinets !=1 && cabinets !=0 )
{
cout<<"Incorrect input regarding the additional counter tops\n";
exit (4);
} else {
//Correct input
optionalFeatures += cabinets * DELUXE_CABINETS;
}
//2.4: House Interior
int floorChoice;
floorChoice = 0.0;
cout << "Now, please make your decision regarding the interior of the home.\n";
cout << "For hard wood floors which cost $10,000, please insert 1.\n";
cout << "For additional solid brass lighting fixtures which cost $20,000, please insert 2.\n";
cout << "For additional specai plush carpeting, ceramic tiles and real wood panels which cost $25,000, please insert 3.\n";
cout << "For gold kitchen and bath fixtures, a Jacuzzi, and a sauna which costs $30,000, please insert 4.\n";
cin >> floorChoice;
switch ( floorChoice )
{
case 1:
optionalFeatures += 10000.0;
break;
case 2:
optionalFeatures += 20000.0;
break;
case 3:
optionalFeatures += 25000.0;
break;
case 4:
optionalFeatures += 30000.0;
break;
default:
cout << "You input an incorrect choice \n";
exit (5);
}
}
//2.5: Discount
if ( optionalFeatures >= 30000.0 )
{
discount=(optionalFeatures * 0.10);
}
else if (optionalFeatures < 30000.0)
{
discount=0;
}
//Calculate
basicHomeCost = House_Square_Footage * COST_PER_SQUARE_FT;
profit = (basicHomeCost + optionalFeatures) * PERCENT_PROFIT;
netHomeCost= basicHomeCost + optionalFeatures + profit - discount;
taxes = netHomeCost * STATE_TAX_RATE;
totalHomeCost = netHomeCost + taxes;
}
//4: Display result
cout << "The basic cost of your home is $"
<< setprecision (2) << fixed << basicHomeCost <<endl;
cout << "Your total discount is $"
<< setprecision (2) << fixed << discount <<endl;
cout << "The total cost of your optional features is $"
<< setprecision (2) << fixed << optionalFeatures <<endl;
cout << "The total cost of your home is $"
<< setprecision (2) << fixed << totalHomeCost <<endl;
} while (repeat == y);
//5: Loop
char loopanswer;
cout << If you would like to try another house, please input y. If you would like to exit now, enter any other number.\n";
cin >> loopanswer;
if ( loopanswer !='y')
{
cout<<"Thank you. Goodbye.\n";
exit (6);
} else {
return 0;
}
|