A closer look at functions - C++
#include <iostream>
using namespace std;
// Declaring gloabal constant
const double FOOT = 7.48051948;
// Function declarations
float CalCubicfeet(float length,float width,float depth);
float calgallons(float cubicFeet);
float costToFillPool(float noOfGallons);
int main()
{
// Declaring variables
float length, width, depth,FillRate;
int fillTime;
// Getting the input entered by the user
cout<<"Enter length:";
cin>>length;
cout<<"Enter width:";
cin>>width;
cout<<"Enter depth:";
cin>>depth;
cout<<"Enter Fill Rate :";
cin>>FillRate;
// calling the functions
float cubicFeet = CalCubicfeet(length, width, depth);
float totalGallons = calgallons(cubicFeet);
float cost = costToFillPool(totalGallons);
fillTime=totalGallons/10;
// Displaying the output
cout<<"Total Cubic Feet :"<<
cubicFeet<<endl;
cout<<"Total Gallons
:"<<totalGallons<<endl;
cout<<"Cost :%.2f $"<<cost<<endl;
cout<<"Fill Time "<<fillTime<<"
minutes"<<endl;
return 0;
}
// This function calculate the cubic feet
float CalCubicfeet(float length,float width,float depth)
{
return length * width * depth;
}
// This function calculate the total gallons
float calgallons(float cubicFeet)
{
return cubicFeet * FOOT;
}
// This function calculate the cost to fill the pool
float costToFillPool(float noOfGallons)
{
int n = noOfGallons / 1000;
if (n >= 0 && n <= 3)
{
return 15.50;
}
else if (n > 3)
{
return 15.50 + (n - 3) * 2.90;
}
}
_________________
Output:
________________
#include <iostream>
using namespace std;
// Declaring gloabal constant
const double FOOT = 7.48051948;
// Function declarations
void PoolSize(float length, float width, float depth,float &cubicfeet,float &gallons);
void FillTime(float gallons,float FillRate,float &Hours,float &Minutes);
int main()
{
// Declaring variables
float length, width, depth;
float cubicfeet,gallons,hours,minutes;
int FillRate;
// Getting the input entered by the user
cout<<"Enter length:";
cin>>length;
cout<<"Enter width:";
cin>>width;
cout<<"Enter depth:";
cin>>depth;
cout<<"Enter Fill Rate :";
cin>>FillRate;
// calling the functions
PoolSize(length, width, depth,cubicfeet,gallons);
FillTime(gallons,FillRate,hours,minutes);
// Displaying the output
cout<<"Total Gallons :"<< gallons<<endl;
cout<<"Fill Time :"<<hours<<" hours and "<<minutes<<" minutes"<<endl;
return 0;
}
// This function calculate the cubic feet
void PoolSize(float length, float width, float depth,float &cubicfeet,float &gallons)
{
cubicfeet=length * width * depth;
gallons=cubicfeet * FOOT;
}
//This function will calculate the tank fill time
void FillTime(float gallons,float FillRate,float &Hours,float &Minutes)
{
int Mins=gallons/FillRate;
Hours=Mins/60;
Minutes=Mins-(Hours*60);
}
________________
Output:
_____________Could you rate me well.Plz .Thank You
A closer look at functions - C++ C option: (The best grade is a 79%) Write...
Write the definition of a class, swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool. Add appropriate constructors to initialize the instance variables. Also add member functions, to do the following: Determine the amount of water needed to fill an empty pool; the time needed to completely...
2. Write a program with three functions that will be called from the main function The functions will calculate the volume, area and perimeter of a cuboid. You should able to pass three parameters such as length, width and height, and a function will return area, another will return volume and final one will return perimeter. Define all your variables in floating point numbers 3. Modify the problem#2 to calculate the volume, area and perimeter in a sing le function...
C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer to have a driveway poured. They can pour a 3 inch deep 200 sq. ft. driveway in 3 hours, and they charge $50.00 per hour as their labor rate. Write a program to ask the user for the length of the driveway (in feet), and the width of the driveway (in feet) to be poured. For both the length and width, make sure the...
program language: python 3 Purpose: Solve a problem by writing multiple functions that perform different subtasks, and combining their use to solve a larger problem. Also to practice documenting functions. Degree of Difficulty: Moderate Your task is to compute the cost of renovating the flooring in a rectangular room. This includes replacing the carpet and and the baseboards. Your task is to write a Python program that calculates and the cost of the renovation. To accomplish this, you will need...
Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The functions are described below on page 2. (Just write the prototypes) When necessary, use the variables declared below in maino. mm 1.) showMenu m2.) getChoice 3.) calcResult m.) showResult 5.) getInfo mm.) showName 7.) calcSquare 8.) ispositive int main { USE THESE VARIABLES, when needed, to write function prototypes (#1 - #8) double num1 = 1.5; double num2 = 2.5; char choice; double result;...
Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++ required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....
This is in c programming using functions in visual studios Carpet Jolb A carpeting company wants to estimate what it will cost a customer to have a room carpeted. They can carpet 65 sq. ft. of room space in 4 hours, and they charge $25.00 per hour as their labor rate Write a program to ask the user for the length of the room (in inches) to be carpeted, the width of the room (in inches) to be carpeted, and...
PLEASE HELP, MATLAB, answers are very appreciated need to study pl 2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan values. The monthly payment M, is calculated using 1-2)1 Where Pis the principal loan amount, r is the interest rate (in decimal form not percent form), and y is the number of years of the loan. Create an m-file function called "mortgage_a.m" that will serve as...
You're to write a C++ program that analyzes the contents of an external file called data.txt. (You can create this file yourself using nano, that produces a simple ASCII text file.) The program you write will open data.txt, look at its contents and determine the number of uppercase, lowercase, digit, punctuation and whitespace characters contained in the file so that the caller can report the results to stdout. Additionally, the function will return the total number of characters read to...