Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello!

I am trying to find how many jelly beans can fit in a jar. so I made some variables.



double height, diameter, beanLength, beanDiameter, glassThickness, radius, newRadius;

double volumeOfJar, airCubicInches, trueVolume, jellyBeanVolume;



as show here. But I need to initialize them. so I tried this



int height;

int diameter;

int beanLength; beanLength = 0.625;

int beanDiameter; beanDiameter = 0.25;

int glassThickness;

int radius;

int newRadius;

int volumeOfJar;

int airCubicInches;

int trueVolume;

int jellyBeanVolume;



But my program does not like that. How do I fix the varibles to be initialized?

What I have tried:

so I tried this



int height;

 int diameter;

 int beanLength; beanLength = 0.625;

 int beanDiameter; beanDiameter = 0.25;

 int glassThickness;

 int radius;

 int newRadius;

 int volumeOfJar;

 int airCubicInches;

 int trueVolume;

 int jellyBeanVolume;
Posted
Updated 12-Oct-21 14:15pm
Comments
jeron1 12-Oct-21 19:42pm    
You've declared beanLength and beanDiameter as integers, 0.625 and 0.25 are not integers. maybe declare them as float or double.

1 solution

Description states they are all double, not int.

Initialize everything inline. For example:
double beanLength = 0.625;
 
Share this answer
 
Comments
CPallini 13-Oct-21 2:31am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900