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
ADVERTISEMENT
Feb 23, 2015
I'm reading in a string from the command line into a char array followed by a series of ints which are read into an int array.
The command line
Code: lab3 word word word 0 0 2 3 results in the following output:
Code: Word: .N=▒
Number of Words: 0
Word: .N=▒word word word
Number of Words: 3
Num: 0
Num: 0
Num: 2
Num: 3
Here is the source code:
int main(int argc, char *argv[]){
if(argc < 2){
//command line must have at least three arguments (one
//char, one integer)
printf("Error: invalid number of arguments
[Code] .....
Where is the .N=▒ coming from?
View 3 Replies
View Related
Nov 5, 2014
To generate output data, I'm printing a bunch of vector contents to files. Because the type of variable can differ between vectors, I wrote a templated printing function to print out whatever the content of the vector is. It looks like this:
template <class T>
void SomeClass::PrintVector(std::vector<T>& Values, std::string& outFile) {
std::ofstream out(outFile, std::ios::app);
[Code] ....
I added the fixed because some larger values were being printed in scientific notation. Everything works well. My test code includes 3 vectors of doubles and 3 vectors of unsigneds. All the unsigneds work well and two of the doubles work well, but the third doubles vector prints nonsense unless I disable the fixed.
The calling code is the exact same. I know the values in the vector are correct, because a) if I comment out the "fixed" flag it works, and b) one of the unsigned vectors is sorted based on the values in that double vector (after it is printed, so the sort cannot corrupt the vector print) and works perfectly.
The "nonsense" looks like chinese/weird characters, if that matters.
View 11 Replies
View Related
Mar 11, 2014
I have a big problem with a function, I wrote this function in order to get a line from an HTML (Or XML) file, until a specified delimiter (not always or
... It can be everything..)
Here is my code :
public static String GetLineUntilChar( String url , char delimiter , String postData, String referer, String cookie ) {
try {
Uri uri = new Uri("http://127.0.0.1//site.html");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.ContentType = "application/x-www-form-urlencoded";
if (!String.IsNullOrEmpty(referer))
request.Referer = referer;
[Code] .....
View 14 Replies
View Related
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
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
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
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
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
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
View Related
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
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
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
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
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
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
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
Jan 3, 2014
i need to calculate crc32 of a input file and check with the original crc value of a file and return true/false,
View 4 Replies
View Related
Aug 8, 2013
I tried to write a simple program to calculate monthly yield, APR, and principle in various directions. Anyway, here's some code to get the APR from the principle and monthly yield. When I run it though, it spits 0 at me every time! What the problem is; the other functions work just fine and the code line for the APR calculation is just what it ought to be - I see neither a math nor tech problem here.
Here is the offending function:
Code:
void calculateAPR() {
int principle, monthlyYield, apr;
cout<<"
Please input the principle:";
cin>>principle;
cin.ignore();
[code]....
View 4 Replies
View Related
Mar 6, 2015
I would like to ask about how we calculates the following bitwise expression.
Code:
unsigned char ch[2] = {0x49,0x49};
ch[0] | ch[1] << 8; I'm thinking ch[1] << 8 as 0x00 ...
So, I think that the above expression converts to 0x49 | 0x00 ... and the complete expression should be 0x49 for me.
But, the compiler gives me the result of 0x4949 as two bytes.How does the compiler calculate this expression as two bytes?show me the steps included in the calculation of this expression?
View 2 Replies
View Related
Apr 9, 2014
I want to have calculations take place inside a switch statement that calls the appropriate function. The menu portion of the program works well, but I can't figure out how to let the user actually input 2 different numbers to the functions. My questions are:
1. If I use scanf to assign values to the variables, what determines end of input to each variable? (ie.. scanf("%d%d", &a, &b) what is the end of a, what is the end of b?)
2. Should I assign the variables to user input inside the switch, or try to do it in the functions below?
3. Is there something I haven't thought to ask that will screw me over? I'm really new to this.
Code:
#include<stdio.h>
int add(int b, int a);
int mult(int b, int a);
main() {
[Code] ....
This really was a test of multilayer menu, but I want to add functionality if I can.
Changed a variable before posting and didn't change all the conditions testing it.
View 3 Replies
View Related
Dec 17, 2013
void viewWasteReport(){
EXEC SQL BEGIN DECLARE SECTION;
char wasteid[5],wastetype[31],month[11],wastequantity[13],wasteweight[11];
//double wastequantity[13];
//double wasteweight[11];
EXEC SQL END DECLARE SECTION;
fnConnectDB();
[Code] ....
I want to obtain the the product of wastequantity*wasteweight, but i get error.
View 6 Replies
View Related
Aug 1, 2013
I am trying to calculate a CRC of a Base64 string.I give you the correct checksum : 2942042514...And now the string :
AQAAAAAAAABsYAAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0d2XIaSbI+hZ13
m0NCR0QNE7KOHcXKlkMwtnhyIIRkdjGwgGxpP35386jqursRsk0zQygkd+dR
lVmVmZVdl//3Xyl+E4/iixiJivgqBmIm5mIoJmIsfhW/iLp4LWrwbwUwY9EH
[code]....
I tried CRC 16, 32 and with polynomial 0xEDB88320L, and with all these tries, I cannot find the correct checksum, it is my main problem.I don't want C++ code source, but I am searching for the method or algorithm to find it. If you want to know, this string in base64 contains an string compressed in zip, which contains an UTF16 XML. I want to modify information, and modify Adobe Projet (prproj)
View 6 Replies
View Related
Oct 1, 2014
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
[Code]....
Write a program that outputs inflation rates for two successive years and whether the inflation is increasing or decreasing. Ask the user to input the current price of an item and its price one year and two years ago.
To calculate the inflation rate for a year, Uh, no, that’s wrong! To calculate the inflation rate for a year, subtract the price of the item ONE YEAR AGO from the price of the item for that year and then divide the result by the price a year ago. For example: 2014-Inflation-Rate = (2014-Price minus 2013-Price) / 2013-Price.
Your program must contain at least the following functions:
•a function to get the input
•a function to calculate the results
•a function to output the results
View 1 Replies
View Related
Dec 9, 2014
I need to create average calculating program using do while loop.
t = 1 - sin(x) when x > 0;
t = 1 + x when x = 0;
t = a + sin(x) when x < 0;
primary information:
x changes from 1 to -1 by step h = -0.5, a = -2
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main() {
int a = -2;
[Code] ....
How this program should look that's why this probably looks just like a mess.
View 2 Replies
View Related
Aug 1, 2013
I am trying to calculate a CRC of a Base64 string. I know the answer of the checksum, but I don't how to calculate it (It is for Adobe project).
I give you the correct checksum : 2942042514
And now the string :
AQAAAAAAAABsYAAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0d2XIaSbI+hZ13
m0NCR0QNE7KOHcXKlkMwtnhyIIRkdjGwgGxpP35386jqursRsk0zQygkd+dR
lVmVmZVdl//3Xyl+E4/iixiJivgqBmIm5mIoJmIsfhW/iLp4LWrwbwUwY9EH
+C1gx+KesH+IjjgTr4Bqj2h+Ey0hxRHQTMQNcHwSV/A0EYsA3oFSFlDngDAf
[Code] ....
I tried CRC 16, 32 and with polynomial 0xEDB88320L, and with all these tries, I cannot find the correct checksum, it is my main problem.
View 12 Replies
View Related