C++ :: Pool Volume - How To Accept Numbers Only

Feb 5, 2014

What I want to do with my program is I want my length, width,volume and price to accept number values only. This is what I have so far.

// This program calculates and displays the pool's volume
// the amount of water needed and the cost.

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
// the double type accepts numbers including fractions for the following inputs.
double length, width, depth, poolvolume, watervolume, price;

[Code] .....

View 1 Replies


ADVERTISEMENT

C++ :: Accept Numbers From User Into Array?

Feb 7, 2015

I want to accept numbers from the user into an array and convert into corresponding alphabets. E.g 1 into A, 2 into B, and so on.

This is simple, but the problem is the user is supposed to enter the character # also which I want to display as it is in the output. How can I do this ? What type of array should be used - int or char?

View 5 Replies View Related

C++ :: Input Validation - Program Cannot Accept Negative Numbers

Nov 12, 2014

#include <iostream>
#include <iomanip>
using namespace std;

// Function Prototype
void sortArray(int array[], int size);

[Code] ....

This program was made to allow students to enter as many test scores as they want and the program will show them in ascending order and then will calculate the average of all test scores. It works wonderful until you enter a negative test score and then it throws the averaging process off. I can't seem to be able to make the program not accept the negative numbers.

View 1 Replies View Related

C/C++ :: Get Volume Of A Box Using Classes

Feb 22, 2015

n the requirements it says this;

-create a get and set for height, width, length.
-A default parameterized constructor = 1
-A method to resize the box
-A method to get the volume of the box
-A method to convert the object to a string

My Questions:

The 3 parts I am confused by are the default parameter constructor, the re-size the box and the method to convert to string. For the default parameter part I figured making length, width and height = to 1 would work, but I'm pretty sure thats not what I'm supposed to do.

This is the main file

#include "box_class.h"
#include <iostream>
using namespace std;
int main() {
double length;
double width;
double height;
double volume;

[Code] ......

View 1 Replies View Related

C++ :: Area And Volume Of Cylinder?

Apr 27, 2013

I would like to calculate area and volume of cylinder but radious and height should be integer, float and double.

View 14 Replies View Related

C++ :: Calculate Area And Volume Of Cylinder?

Apr 27, 2013

I would like to calculate area and volume of cylinder but radious and height should be integer, float and double. How can i do?

View 9 Replies View Related

C++ :: Save Big Volume Of Computation Results

Feb 27, 2013

I run some computations which give a big number of vectors (let's say 100 vectors, each one contain 2000 elements of type double). I want to save those data and import them into Excel.

I know I can save the results through in txt file. But it would be a very long file. Can I save the results in other more efficient file form that can be imported into Excel? and how?

View 7 Replies View Related

C++ :: Cone Volume Calculator Program

Nov 6, 2014

I'm working on below program and I want the program to do the same thing, but with not one main() function, but instead one main() function PLUS one user defined function called computeConeVolume that contains the calculation. In other words I want to remove the one line calculation and replace it with a function call, then write and add the function below main with the calculation, surrounded any other syntax that I need to complete it.

The function should contain local variables and a constant declared and must have the calculation, it may not do anything else such as input or output. Should be able to declare "global" variables anywhere but no variables above or outside of main() and the function are allowed. A value-returning function should be used because it's a little simpler to understand, but you can employ a void function. Need to have a function prototype at the top of the code, then main, then your function.

//Cone Volume Calculator Program
#include <iostream>
using namespace std;
int main( ) {
//Declare variables and constants
double coneRadius = 0.0;
double coneHeight = 0.0;

[Code] ....

View 6 Replies View Related

C++ :: Getting Strange Print Out For Calculation Of Volume

Apr 4, 2013

// DEBUG3-4
// This program contains a class for a cylinder
// Data members are radius and height
// The volume is calculated as pi times radius squared times height
// If no height is given, it's not a cylinder - it's a circle!

#include<iostream>
using namespace std;
//declaration section

[Code].....

View 1 Replies View Related

C++ :: Import Stock Ticker And Volume From A Website?

Mar 30, 2014

I need a line of code of retrieving data from a live website. I will look around in the mean time. libcurl?

View 1 Replies View Related

C++ :: Mathematically Check For 3D Point Inside Volume?

May 3, 2013

In 2D I checked to see if a point was inside a shape by creating triangles between 2 neighbouring points and the centre of the object, then checking the angle to the 3 points from the test point and if the sum = 360... If not then it isn't inside the triangle. But how would I check if a point is inside a volume rather than an area? I know the same method would work but I don't think very well as it'll be testing with the thickness of the shell of the 3D object, which may be quite easily jumped in a single frame of movement..

View 8 Replies View Related

C/C++ :: Circle Paper Of Radius R - Max Cone Volume

Jan 23, 2014

My problem is the following : We have a circle paper of radius R. We will cut off a sector of this circle (with length rem_sec), and the remaining (bigger part) will create a cone. Radius of cone base is r.

I need to create a code that prompts the user to enter circle's radius R and the program will calculate the length of removed sector (rem_sec) so that the created cone has the Max Volume.

I wrote the following code, but it doesn't work. It displays both rem_sec and MaxV = 0.

#include <iostream>
#include <cmath>
#include <iomanip>
#include <conio.h>
using namespace std;
const double PI = 3.1415;
int main() {
double rem_sec;

[Code] ...

View 5 Replies View Related

C :: How To Calculate Surface Area And Volume For Rectangular Prism

Jan 24, 2015

So for my assignment, I have to write code to calculate the surface area and volume for a rectangular prism that involves the use of functions. I made the program without functions and it works perfectly but as I'm putting in the required functions, it conversely made it non-functional, ironically. How to call functions correctly and the online book we're using now is confusing me even more.

Code:

#include <stdio.h>
#include <math.h>
int main(void) {
double x1, x2, x3, x4, x5, x6, x7, x8 = 0;
double y1, y2, y3, y4, y5, y6, y7, y8 = 0;
double z1, z2, z3, z4, z5, z6, z7, z8 = 0;
double length, width, height=0;

[Code]....

And here is the version I'm using to test it (without the need to input the individual coordinates).

Code:

#include <stdio.h>
#include <math.h>
int main(void) {
double x1, x2, x3, x4, x5, x6, x7, x8 = 0;
double y1, y2, y3, y4, y5, y6, y7, y8 = 0;
double z1, z2, z3, z4, z5, z6, z7, z8 = 0;
double volumePrism, surfaceArea =0;

[Code]...

View 3 Replies View Related

Visual C++ :: Arrays - Solve Equation Using All Volume Values

Dec 22, 2012

I am using matlab R2o11 in which the programming medium is c++. I am having these variables=

T=373 t0 376
V=0.09 to 1
P=T/V

I just need a result showing ... First it should take T=373 and solve the equation using all volume values. Then it takes another temperature and do the same.

View 4 Replies View Related

C++ :: Input Length / Width And Height For 3 Boxes - Sum And Average Volume

Dec 6, 2013

How would I make it so that I can have someone input the length, width and height for all 3 boxes and then have it output the sum and average volume? Here's an example of what I would like:

INPUT - Enter Box 1 (Length, Width, Height): 10.1 11.2 3.3
INPUT – Enter Box 2 (Length, Width, Height): 5.5 6.6 7.7
INPUT – Enter Box 3 (Length, Width, Height): 4.0 5.0 8.0
OUTPUT – The sum of the volume is 812.806
OUTPUT – The average volume is 270.935

Here's my original code:

#include <iostream>
using namespace std;
double box(double length, double width, double height); // use double data
int main() {
double sum;
sum = box(10.1, 11.2, 3.3) + box(5.5, 6.6, 7.7) + box(4.0, 5.0, 8.0);

[Code] .....

View 1 Replies View Related

C/C++ :: Calculate Volume Of A Cone With Values For Diameter Of Base And Height

Jan 30, 2014

I am having trouble with calculating the volume of a cone

Assignment: Using the knowledge you already have, create, build, run, and correct if necessary a program that will calculate the volume of a cone. Insert into your code values for diameter of the base and the height. Use variables, constants, literals, and mathematics as necessary.

The formula for the volume is:

1/3 π x Radius2 x Height

Hint: you will need to add to your program two lines where appropriate:

#include <cmath>
const double PI = 2*acos(0.0);

Here is my current code:

#include <iostream>
using namespace std;
int main () {
//diameter of the base
float diameter = 3;

[Code] ....

View 3 Replies View Related

C :: Pointer - How To Accept 50 Names

Mar 24, 2013

char *name[50]

How to accept 50 names using above definition...

View 3 Replies View Related

C++ :: Using Cin That Accept Multiple Inputs

Feb 14, 2013

For a program I am required to use a cin that accepts 4 variables. The first describes a function such as add(), remove(), print(), or quit(). The problem is that to use add() I need to input all 4 variables but for remove(), only 2 variable input is needed.

I want the input to be "add 9 James Bond"
or be "remove 341"

Here is my current code.

int command(string command, int Id, string first, string last){
while (command != "quit"){
cout << "customers> ";
cin >> command >> Id >> first >> last;
if (command == "add")

[Code] .....

View 1 Replies View Related

C++ :: How To Make Cin Accept Different Punctuation From Vector

Mar 7, 2013

My program is a dictionary vector with a cin at the end that will read your input and check if it's in the dictionary.

#include "std_lib_facilities_3.h"
#include <algorithm>
#include <string>
#include <iostream>

string translate_to_lower(string s){
transform(s.begi[/code]n(), s[/code].end(), s.begin(), (int (*)(int)) tolower);

[Code] ...

How do I make the program accept inputs such as "hello?", "hello!", and "hello,"?

View 1 Replies View Related

C++ :: Accept Multiple Data Types

Jun 17, 2014

Basically I do not want to use a menu, instead just accept either an float or a single character. Then send the data to the appropriate spot based on the user input. I have been unable to convert the char to a float, and even if I did the char would probably only accept the first digit, say user enters '15' it would only read the '1'. I've tried strings instead of char but then unable to use the isalpha function. Do I need a char[] and then iterate through to get the numeric data? Then how do i make '1' and '5' become 15. There is probably a solution. I've also tried to use a loop waiting for the correct data while(!(cin >> letter)) which works but how do I get out if the user enters number.

#include <iostream>
#include <cctype>
#include <string>
#include <cstdlib>
using namespace std;

[code].....

View 3 Replies View Related

C++ :: Create Program That Will Accept 2 Integers?

Sep 4, 2013

how can I create a program that will accept 2 two integers. the user will also choose among the different operations:

1 for addition
2 for subtraction
3 for multiplication
4 for division

View 4 Replies View Related

C++ :: Program That Accept Input For User ID

Oct 28, 2013

I need a program to run that will accept an input for user id. It will take the customer input and capitalize the letters, and return invalid id with the user inputted values. Then if it's valid it will add a counter counting the number of letters and numbers. It will keep track until the user puts in !. It seems when I try to pass values from the array to my toUpper function to capitalize it it doesn't seem to work right.

View 3 Replies View Related

C++ :: RPG Game - Function Call Does Not Accept Argument

Apr 20, 2013

I was trying to look up solution for this for quite a while already but found nothing. I am writing a simple console based turn based RPG game for my class project. I was trying to have a member function attack() in class of the player character, which affects the component called health of the class Enemy. both this classes are inherited from the base class Unit. I tried to pass the object of type enemy as an argument to the function attack, but the function call gives me Error: too many arguments in function call. Here's the code for classes:

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;

class Unit {
protected: int power, intellect;

[Code] ....

View 5 Replies View Related

C# :: Accept Two Input Parameter And Returns Two Out Values

Jan 26, 2014

class Program {
//Accept two input parameter and returns two out value
public static void rect(int len, int width, out int area, out int perimeter) {
area = len * width;
perimeter = 2 * (len + width);

[Code] .....

why is the static keyword required in the method signature for the rect() method. It will not compile if it is absent. why?

the same is true for this example:

class Program {
static void printvalues(params int[] passedin) {
foreach (var printthis in passedin) {
Console.WriteLine(printthis);

[Code] ....

This code won't compile without the static keyword in the printvalues() method signature. why?

View 13 Replies View Related

C/C++ :: Instead Of String - Accept Answer With Space In Between Words

Jun 13, 2014

string answer;
cout<<"5.Newton's which law states that F=ma?";
cin>>answer;
if (answer == "newton's second law")

[Code].....

View 6 Replies View Related

C/C++ :: Binary Search Tree That Will Accept Integers?

Feb 28, 2015

Create Binary Search Tree that will accept integers in this order: 35, 18, 48, 72, 60, 25.

It needs to prompt the user for input and then return either "True" or "False" if the number exists in the array.

#include <iostream>
#include <string>
#include <cstdlib>

[Code].....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved