Assume you are looking to buy a house in a new development. After looking at various models, the three models they like are majestic, split-entry, and single-story.The builder gave them the base price and the finished area in square meters of three models. They want to know the model(s) with the least price per square feet. Write a program that accepts as input the base price and the finished area in square meters of the three models. The program outputs the model(s) with the least price per square meter.
/* Find the model with the least price per square feet */ for (short t = 1; t < modelCount; t++) { tmp = basePrice[t] / finishedArea[t]; if (tmp < theLeastPrice) theLeastPrice = tmp; }
for (short g = 0; g < modelCount; g++) if (basePrice[g] / finishedArea[g] == theLeastPrice) leastPriceModels[g] = true; return theLeastPrice; }
for (short c = 1; c <= 3; c++) { cout << "Enter the base price of the model #" << c << ": "; cin >> basePrice[c - 1]; cout << "Enter the finished area of the model #" << c << ": "; cin >> finishedArea[c - 1]; cout << endl; }
cout << endl; for (short y = 0; y < 3; y++) if (leastPriceModels[y]) cout << "The model #" << y + 1 << " with the lowest price per square meter of " << lowestPrice << "." << endl;
Comments
Leave a comment