Question

In: Computer Science

TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Summary Samantha and Vikas are looking...

TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING)

C++ CODE

Summary

Samantha and Vikas are looking to buy a house in a new development. After looking at various models, the three models they like are colonial, split-entry, and single-story.

The builder gave them the base price and the finished area in square feet of the three models. They want to know the model(s) with the least price per square foot.

Instructions

Write a program that accepts as input the base price and the finished area in square feet of the three models.

The program outputs the model(s) with the least price per square foot in the following format:

If the colonial model is the least price, output:

  • The price per square foot of the colonial model is the least.

If the split-entry model is the least price, output:

  • The price per square foot of the split-entry model is the least.

If the single-story model is the least price, output:

  • The price per square foot of the single-story model is the least.

If the colonial and split-entry models tie for the least price, output:

  • The price per square foot of the colonial and split-entry models tie for the least.

If the colonial and single-story models tie for the least price, output:

  • The price per square foot of the colonial and single-story models tie for the least.

If the single-story and split-entry models tie for the least price, output:

  • The price per square foot of the single-story and split-entry models tie for the least.

Finally, if all three tie for the least price, output:

  • The price per square foot all three models are the same.

Solutions

Expert Solution

Thanks for the question.


Here is the completed code for this problem. Comments are included so that you understand whats going on. Let me know if you have any doubts or if you need anything to change.


Thank You !!


========================================================================================

#include<iostream>
#include<string>

using namespace std;

void printLeastPrice(double,double,double);

void printLeastPrice(double col,double split,double single){
  
   if(col<split && col<single){
       cout<<"The price per square foot of the colonial model is the least.\n";
   }else if(split<col && split<single){
       cout<<"The price per square foot of the split-entry model is the least.\n";
   }else if(single<col && single<split){
       cout<<"The price per square foot of the single-story model is the least.\n";
   }else if(col==split && col<single){
       cout<<"The price per square foot of the colonial and split-entry models tie for the least.\n";
   }else if(col==single && col<split){
       cout<<"The price per square foot of the colonial and single-story models tie for the least.\n";
   }else if(single==split && single<col){
       cout<<"The price per square foot of the single-story and split-entry models tie for the least.\n";
   }else if(col==split && split==single){
       cout<<"The price per square foot all three models are the same.\n";
   }
   cout<<endl;
}

int main(){
  
  
   double colonialBasePrice, splitBasePrice, singleBasePrice;
   double colonialArea, splitArea, singleArea;
   double colonialPriceSqFt, splitPriceSqFt, singlePriceSqFt;
  
   // get user input for all the 3 models
   cout<<"Colonial Model:"<<endl;
   cout<<"Enter Base Price: "; cin>>colonialBasePrice;
   cout<<"Enter finished area: "; cin>>colonialArea;
   colonialPriceSqFt = colonialBasePrice/colonialArea;
  
   cout<<"Split-Entry Model:"<<endl;
   cout<<"Enter Base Price: "; cin>>splitBasePrice;
   cout<<"Enter finished area: "; cin>>splitArea;
   splitPriceSqFt = splitBasePrice/splitArea;
  
   cout<<"Single-story Model:"<<endl;
   cout<<"Enter Base Price: "; cin>>singleBasePrice;
   cout<<"Enter finished area: "; cin>>singleArea;
   singlePriceSqFt = singleBasePrice/singleArea;
  
   // uncomment to print the prices per sq ft for all the 3 models.
   //cout<<"Colonial Price/Sqft: "<<colonialPriceSqFt<<endl;
   //cout<<"Split-Entry Price/Sqft: "<<splitPriceSqFt<<endl;
   //cout<<"Single=story Price/Sqft: "<<singlePriceSqFt<<endl;
  
   printLeastPrice(colonialPriceSqFt,splitPriceSqFt,singlePriceSqFt);
  
  
}

=====================================================================================

thanks a lot !!


Related Solutions

TEXT ONLY PLEASE ( PLEASE NO PDF OR WRITING) C++ CODE Instructions In a right triangle,...
TEXT ONLY PLEASE ( PLEASE NO PDF OR WRITING) C++ CODE Instructions In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. If the triangle is a right triangle, output It is...
TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Instructions Write a program that implements...
TEXT ONLY PLEASE (PLEASE NO PDF OR WRITING) C++ CODE Instructions Write a program that implements the algorithm given in Example 1 - 3 (Chapter 1), which determines the monthly wages of a salesperson. The instructions for Example 1 - 3have been posted below for your convenience. Example 1 - 3 Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month, based on the following criteria: If the salesperson has been with...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ PLEASE Summary For each used...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ PLEASE Summary For each used car a salesperson sells, the commission is paid as follows: $20 plus 30% of the selling price in excess of the cost of the car. Typically, the minimum selling price of the car is the cost of the car plus $200 and the maximum selling price is the cost of the car and $2,000. Instructions Write a program that prompts the user to enter:...
please use text only! Instructions Consider the provided C++ code in the main.cpp file: The function...
please use text only! Instructions Consider the provided C++ code in the main.cpp file: The function func2 has three parameters of type int, int, and double, say a, b, and c, respectively. Write the definition of func2 so that its action is as follows: Prompt the user to input two integers and store the numbers in a and b, respectively. If both of the numbers are nonzero: If a >= b, the value assigned to c is a to the...
USING C++ ONLY. Please study the code posted below. the goal is to rewrite the code...
USING C++ ONLY. Please study the code posted below. the goal is to rewrite the code implementing a template class using a linked list instead of an array. Note: The functionality should remain the same. /** * Queue implementation using linked list C style implementation ( no OOP). */ #include <cstdio> #include <cstdlib> #include <climits> #include <iostream> #define CAPACITY 100 // Queue max capacity using namespace std; /** Queue structure definition */ struct QueueType { int data; struct QueueType *...
provide a C code (only C please) that gives the output below: ************************************ *         Menu HW...
provide a C code (only C please) that gives the output below: ************************************ *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1. Creating polynomials * * 2. Adding polynomials * * 3. Multiplying polynomials. * * 4. Displaying polynomials * * 5. Clearing polynomials. * * 6. Quit. * *********************************** Select the option (1 through 6): 7 You should not be in this class! ************************************* *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1. Creating polynomials...
C language only please and please make a simple code Write a function that will find...
C language only please and please make a simple code Write a function that will find whether there exist two integers that sum to the target integer. The function is to “return” three values.First, return “1” if the integers were found,return “-1” if your search was not successful.If you find two integers which add up to the target value, you should return their respective index position inside the array. Suggested prototype:int TwoSumFunction(int arr[], int size, int target, int*index1, int* index2);Inside...
Please do this in C++ only. Please Show your code and your output too. Would you...
Please do this in C++ only. Please Show your code and your output too. Would you focus on number 2 in the Required functions:? Please use all the variables in the program. The assignment problem: You are asked to develop an application that prints a bank’s customers' names, IDs, and accounts balances in different ways. In this program, you need to read a file of customer’s data into different arrays, pass these arrays to functions as (array parameter), calculate the...
Please, write code in c++. Using iostream library Most modern text editors are able to give...
Please, write code in c++. Using iostream library Most modern text editors are able to give some statistics about the text they are editing. One nice statistic is the average word length in the text. A word is a maximal continuous sequence of letters ('a'-'z', 'A'-'Z'). Words can be separated by spaces, digits, and punctuation marks. The average word length is the sum of all the words' lengths divided by the total number of words. For example, in the text...
Using C++, write a code that this program always stores text file output into a text...
Using C++, write a code that this program always stores text file output into a text file named "clean.txt". -The program should read one character at a time from "someNumbers.txt", and do the following. -If it is a letter, print that letter to the screen, AND also store it in the text file. All letters should be converted to lowercase beforehand. -If it is a number, print that number to screen, but do NOT store it in the text file....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT