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


ADVERTISEMENT

C# :: Width And Height For Column And Rows

Mar 21, 2014

Basically when I type in different widths and heights for the col and rows, the buttons that make up the width get cut off. Something is messed up but I'm not sure what!

InitializeComponent();
int _col = int.Parse(cols);
int _row = int.Parse(rows);
int width = groupBox1.Width;
int height = groupBox1.Height;
int bW = width / _col;
int bH = height / _row;

[Code] ....

View 4 Replies View Related

C/C++ :: How To Use Rectangle Height And Width In Functions

May 13, 2014

The problem says:

Define functions n(), s(), e(), w(), center(), ne(), se(), sw() and nw(). Each takes a Rectangle argument and returns a Point. These functions define connection points on and in the rectangle. For example, nw® is the northwest (top-left corner) of a rectangle called r.

I wrote below code for that:

#include <Simple_window.h>
Point n(const Graph_lib::Rectangle& r);
Point s(const Graph_lib::Rectangle& r);
Point e(const Graph_lib::Rectangle& r);
Point w(const Graph_lib::Rectangle& r);
Point ne(const Graph_lib::Rectangle& r);
Point se(const Graph_lib::Rectangle& r);

[Code]...

As you see, this just mark the top-left corner of the rectangle r. In other functions I need the specifications of that rectangle, for example its height and width. How to use these specs in those functions?

View 2 Replies View Related

Visual C++ :: Width And Height From HBITMAP?

Sep 5, 2013

If I get a bitmap from the clipboard with:

hBitmap=(HBITMAP)GetClipboardData(CF_BITMAP);

...how do I get the width and height ? Can I get at the BITMAPINFO ?

View 2 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

Visual C++ :: How To Change Height And Width Of PNG Image Dynamically

Mar 4, 2013

I m trying to load a png image by giving the dimension of my own.

CImage Image;
Image.Load (L"D:ImagesPNG_ImagesImage7.png");

But here what happens is that I m not able to give my own dimensions.My code requires constant changing of dimensions of the image.

I tried using libpng.lib in my code.But I dono the keywords for loading the png image after including the lib.

I m using Visual Studio 2010. I m developing in vc++.

How do I load and change the height and width of a png image?

View 4 Replies View Related

C++ :: Demonstrate Usage Of Each Member Function Using Test Data (width And Height)

Feb 11, 2013

Provide the definitions for the following class declaration and then write a program that demonstrates usage of each member function using the test data of 10 for width and 8 for height. Remember to put your main program, class header and class source into separate files. This is an easier version of the exercise than the one you have been asked to practice. Only provide code for the methods specified in the class declaration. Note that the displayRectangle() method should output an appropriate ‘box’, its dimensions, area and perimeter to the screen.

class Rectangle {
public:
Rectangle(int height, int width);
~Rectangle(void);

[Code] .....

View 1 Replies View Related

C++ :: Print Out Square Of Stars With Different Length And Width Given?

Feb 27, 2013

#include <iostream>
using namespace std;
int main()
{

[Code].....

how do i change this code to accept two numbers from the user and print it as the different length and widtth? it has to be a for loop as well.[code]

View 5 Replies View Related

C++ :: Set Width Of Data Values Which User Will Input

Sep 24, 2014

I am trying to set the width of the data values which the user will input when using the program but I don't know how to get it to show the values when I tryto set the width of the variables in a nice column .

//Programming Assignment 4

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
int main() {
double q1r1, q2r1, q3r1, q4r1;
double q1r2, q2r2, q3r2, q4r2;
double q1r3, q2r3, q3r3, q4r3;

[Code] ....

View 2 Replies View Related

C/C++ :: Input User Name And Height In Inches And Output In Centimeters

Oct 22, 2012

I am attempting to write a simple C program, in which the user is asked to input their name and height in inches and the output is the user's height in centimeters.

I have attached my program and what happens when I try to run it.

Attached Images : PM.jpg (120.6 KB)

View 1 Replies View Related

C :: Calculate Different Measurements For A Cylinder - Width Modifier For End User Input

Sep 12, 2013

I have created a program to calculate different measurements for a cylinder. Anyways, the end user has to input 3 variables.

Enter the lower radius: 6
Enter the upper radius: 5
Enter slant height: 2.236

The numbers are what "End User" would input. But I need to make it look like this when said "End User inputs the numbers.

Enter the lower radius: 6
Enter the upper radius: 5
Enter slant height: 2.236

Here is what I have for it, but I don't know what to put where.

printf("
Enter the lower radius: ");
scanf("%f", &lower_rad);
printf("Enter the upper radius: ");
scanf("%f", &upper_rad);
printf("Enter slant height: ");
scanf("%f", &slant_h);

View 1 Replies View Related

C :: How To Validate The Length Of User Input

Oct 24, 2013

For the following program, I'd like to make sure the user input is between 1 and 40 characters. To do this, how would I complete the if statement below?

Code:
char p_input[41];
printf("Enter a name (1-40 characters):");
fgets(p_input, 41, stdin);

if (p_input ....??

View 6 Replies View Related

C/C++ :: Find Length Of First Sentence In Input String

Feb 13, 2015

I have a question about finding the length of first sentence in an input string.

For example, let the input string be: dream in code. community learning

The length of first sentence is 13 (blanks are included). My question is how to create conditions for multiple punctuation signs (!,?)? If while loop goes like:

while((str[i]!='.')||(str[i]!='!')||(str[i]!='?'))

it gives me an error for infinite loop.

Code:
#include<stdio.h>
int main() {
char str[100];int i=0,br=0;
printf("enter a string:");
gets(str);

[Code] ....

View 1 Replies View Related

C++ :: Fscanf And Verifying Correct Input Length

Jan 24, 2012

I am trying to make a program that will read in input in the following format:

| ...text... || ...more text... || ...still more text...|

i.e. every bit of "text" that gets read in is bracketed on either side by the "|" character.

The buffer that i read them into can be of a maximum length of 101 (100 characters plus a terminating null character); this is how I am currently reading in the input:

char readString [100 + 1];
while ( fscanf(infile, "|%1000[^|]|", readString) ){
/*... manipulate readString ...*/
}

How might I design this program so that, should any of the text appearing between the "|" characters exceed 100 in length, it exits and returns a warning?

View 4 Replies View Related

C++ :: Input Number During Runtime - variable Array Length

Nov 28, 2013

I want to ask for a number as an input during runtime and then create an 2-dimensional array of size as specified by user. i.e. if the user inputs 3, the array should be of size 3X3, and likewise...

View 9 Replies View Related

C++ :: Dynamic Arrays - Sort Input Data And Calculate Average

Jul 15, 2014

I'm still fairly new to c++ and am having trouble with dynamic arrays. My task is to create an array for test scores. The user needs to define the size of the array and then input data to later sort and calculate the average.

Below is what I have so far. I am struggling with the user input part. I receive the following errors for the data input of the individual scores:

"error C2108:subscript is not of integral type"
"IntelliSense:expression must have integral or unscoped enum type"

Code :

#include<iostream>
#include<iomanip>
using namespace std;
int main() {
//user input total number of scores
cout<<"Please enter the total number of test scores."<<endl<<endl;

[Code] ....

View 1 Replies View Related

C++ :: Using A For Loop To Input And Output Array Values Also Calculate The Average

Jan 24, 2014

I have this code that im stuck on what i need to do is Extend the code such that when it starts the user is asked to input values to specify each of the three ranges before moving on to accept and tally the main values how do i do that Using a for loop to input and output array values Also calculate the average

*/
#include <stdio.h>
int main(void)
{
/* Declare an array of integers */
int Grades[5];
int nCount;
int nTotal = 0; /* Declare and initialise the value */
float fAverage;

[Code]...

View 1 Replies View Related

C :: Print Correct Normalized Value / Average And Values Above Average

Nov 14, 2013

I must write a function that has a one dimensional double array and the number of values in the array as its arguments. Normalize the values. I must also print the maximum, minimum, average and numbers of values above the average in the array.

The equation that computes the normalized value from a value x is:

Normalized x= (x-min(array))/(max(array)-min(array))

My code does not print the correct normalized value, average and values above average.

Code:
#include <stdio.h>
int findMax( double array1[], int num_elements) // This function computes the maximum value of the array
{
int i, max=-32000;
for (i=0; i<num_elements; i++)

[Code] .....

View 5 Replies View Related

C++ :: Average Negative / Positive Numbers And Total Average?

Nov 18, 2013

I am trying to average the negative numbers and positive number and of course the total average.

This will read in a list of n values, where n is not known ahead of time. The number of values read into the array will be saved in n.

vector<int> readList() {
std::vector<int> result;
ifstream inFile;
inFile.open("setA.txt");
for (int x; inFile >> x; ) {
result.push_back(x);

[code]....

array is a one-dimensional array of integers and n is the number of elements in that array that contain valid data values. Both of these are input parameters to the function. The function must calculate 1) the average of the n integers in array, storing the result in ave; 2) the average of the positive numbers (> 0), storing the result in avePos, and 3) the average of the negative numbers (< 0), storing the result in aveNeg.

void avgs (std::vector &array, int &ave, int &avePos, int &aveNeg) {
int sum = 0, pos_sum = 0, neg_sum = 0, pos_count = 0, neg_count = 0;
for (auto i : array) {
sum += i;
if (i > 0) { pos_sum += i; ++pos_count; }

[code]....

View 1 Replies View Related

C++ :: Distributing Quantity R In M Boxes

Feb 24, 2014

I have an array of size m and r resources. What would be an efficient (or just any) way of distributing them in the way shown in the table? The highest amount of resources must be concentrated in the middle of the array and all the resources must be distributed.

I'm not really set on exactly how steep the "slope" must be, I just need a way of approaching the problem.

Example with m=9 and r=13

box resources
0 0
1 0
2 2
3 2
4 4
5 2
6 2
7 1
8 0

View 3 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# :: Using Check Boxes To Find Total Value?

Mar 1, 2015

Basically, I am designing a form that shows all of the services a mechanic performs, and then it is supposed to calculate the total based on the selections made.

HOW do I use those check boxes to calculate a total? I am supposed to use value-returning methods that solve for the parts cost, flush charges, tax charges, misc costs, etc. Ive attached a picture of the form thus to make sense of what I'm trying to describe.

View 5 Replies View Related

C# :: Proper Validation Of Text Boxes?

Dec 1, 2014

So I am writing a multiform multiclass project for a class and I initially set out to create a validate class to check all of my text boxes. However after writing a few simple boolean functions to check if the box was empty or not, or if it was indeed an integer, decimal ect. I realized I was going to have to call these functions for every text box and also have all of my decision making based on the returned boolean variable still in the code portion of my form. I was wondering how do most people do it, should I write a class that validates the entire form at once(one form has 7 text boxes, one has 9). I suppose I am asking what would the industry standard be, how would a professional do it? While my simple functions would work, and while I could write one large function that validates them all at once both paths leave something to be desired in terms of re-usability for the entire form validation, and compact/cleanliness of code for the simple functions.

My validate class currently stands like this:

class Validate {
bool isValid = true;
int trash;
bool valid_string(string input) //parameter is textbox.text property {
if (input == string.Empty)

[Code] ......

View 7 Replies View Related

C# :: Why Multiple Entries In Combo Boxes

Oct 3, 2014

Why multiple entries in combo boxes?

private void Form1_Load(object sender, EventArgs e) {
try {
connection.Open();
OleDbCommand command=new OleDbCommand();
command.Connection=connection;
string query="select * from korisnici,dogadjaji";

[code]...

View 14 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/C++ :: How To Randomize Images In Multiple Picture Boxes

May 9, 2014

Here's what i'm searching for: I have a form with 3 pictureBoxes (pictureBox1,2,3). The form also contains one button.

What I want is that when the user clicks the button (so button_click event) that the 3 pictureBoxes each show a different picture. And when I click the button again again 3 different pictures will load.

I already found out that I need to make an arraylist for the pictures (there are about 100 pictures). A System.Random
to select random images. But I have absolutely no clue on how to write this code.

View 5 Replies View Related







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