delphi3
asked on
Expanding formula statement automatically.
Hi All,
Given these 2 formulas of y =....... which are dependent on the number of atoms.length, and they appear to be consistantly applied, I want to make the formulas appear so that as the number of atoms.length increased causes the formula y =....... to expand accordingly.
This is demonstrated in the two situations below:
............. start of snip
int atmlength = atoms.length;
if (atmlength == 3) // 2nd degree
{
y = Float.parseFloat(atoms[ato ms.length- 1]) +
gofrmX*(Float.parseFloat(a toms[atoms .length-2] ) +
gofrmX*Float.parseFloat(at oms[atoms. length-3]) );
}
if (atmlength == 4) // 3rd degree
{
y = Float.parseFloat(atoms[ato ms.length- 1]) +
gofrmX*(Float.parseFloat(a toms[atoms .length-2] ) +
gofrmX*(Float.parseFloat(a toms[atoms .length-3] ) +
gofrmX*Float.parseFloat(at oms[atoms. length-4]) ));
}
end of snip...........
Delphi3
Given these 2 formulas of y =....... which are dependent on the number of atoms.length, and they appear to be consistantly applied, I want to make the formulas appear so that as the number of atoms.length increased causes the formula y =....... to expand accordingly.
This is demonstrated in the two situations below:
............. start of snip
int atmlength = atoms.length;
if (atmlength == 3) // 2nd degree
{
y = Float.parseFloat(atoms[ato
gofrmX*(Float.parseFloat(a
gofrmX*Float.parseFloat(at
}
if (atmlength == 4) // 3rd degree
{
y = Float.parseFloat(atoms[ato
gofrmX*(Float.parseFloat(a
gofrmX*(Float.parseFloat(a
gofrmX*Float.parseFloat(at
}
end of snip...........
Delphi3
y = Float.parseFloat(atoms[ato ms.length- 1])
for(int i = 2; atomlength <=atmlength ; i++){
y+= gofrmX*Float.parseFloat(at oms[atoms. length-i])
}
or
y = Float.parseFloat(atoms[ato ms.length- 1])
for(int i = 2; atomlength <=atmlength ; i++){
y+= gofrmX*Float.parseFloat(at oms[i])
}
for(int i = 2; atomlength <=atmlength ; i++){
y+= gofrmX*Float.parseFloat(at
}
or
y = Float.parseFloat(atoms[ato
for(int i = 2; atomlength <=atmlength ; i++){
y+= gofrmX*Float.parseFloat(at
}
y = Float.parseFloat(atoms[ato ms.length- 1])
for(int i = 2; i <=atmlength ; i++){
y+= gofrmX*Float.parseFloat(at oms[i])
}
for(int i = 2; i <=atmlength ; i++){
y+= gofrmX*Float.parseFloat(at
}
ASKER
expertmb,
Thanks for your java statements .
Surprised that some of the punctuation is missing like ";".
Still none of the statements above fill the bill.
Any more suggestions?
D#
Thanks for your java statements .
Surprised that some of the punctuation is missing like ";".
Still none of the statements above fill the bill.
Any more suggestions?
D#
hmmmmmm missed semicolons.
if the code is not lenghty can you post the code.
if the code is not lenghty can you post the code.
class formulaTest{
public static void main(String[] s){
//String atoms[] = {"1","2","3"};
String atoms[] = {"1","2","3", "4"};
int atmlength = atoms.length;
float y = Float.parseFloat(atoms[0]) ;
for(int i = 1; i <atmlength ; i++){
y+= Float.parseFloat(atoms[ato ms.length- i]);
}
System.out.println("y: " + y);
}
}
public static void main(String[] s){
//String atoms[] = {"1","2","3"};
String atoms[] = {"1","2","3", "4"};
int atmlength = atoms.length;
float y = Float.parseFloat(atoms[0])
for(int i = 1; i <atmlength ; i++){
y+= Float.parseFloat(atoms[ato
}
System.out.println("y: " + y);
}
}
modified
class someTest{
public static void main(String[] s){
//String atoms[] = {"1","2","3"};
String atoms[] = {"1","2","3", "4"};
int atmlength = atoms.length;
float x = 0.5f;
float y = Float.parseFloat(atoms[atm length-1]) ;
for(int i = 2; i <=atmlength ; i++){
System.out.println(atoms[a toms.lengt h-i]);
y+= (Float.parseFloat(atoms[at oms.length -i]))*x;
}
System.out.println("y: " + y);
}
}
class someTest{
public static void main(String[] s){
//String atoms[] = {"1","2","3"};
String atoms[] = {"1","2","3", "4"};
int atmlength = atoms.length;
float x = 0.5f;
float y = Float.parseFloat(atoms[atm
for(int i = 2; i <=atmlength ; i++){
System.out.println(atoms[a
y+= (Float.parseFloat(atoms[at
}
System.out.println("y: " + y);
}
}
ASKER
Sorry to post it this way,
but at the moment it seems more efficient.
see my initial post at
https://www.experts-exchange.com/questions/21131187/Automating-a-formula.html
and you should see the snip that I put above.
Hope that this help in clarifying the difficulty. Thie notes at the top of it present a few sample problems.
D3
but at the moment it seems more efficient.
see my initial post at
https://www.experts-exchange.com/questions/21131187/Automating-a-formula.html
and you should see the snip that I put above.
Hope that this help in clarifying the difficulty. Thie notes at the top of it present a few sample problems.
D3
class someTest{
public static void main(String[] s){
String atoms[] = {"1","2","3"};
//String atoms[] = {"1","2","3", "4"};
int atmlength = atoms.length;
float x = 0.5f;
float y = 0.0f;//Float.parseFloat(at oms[atmlen gth-1]);
for(int i = atmlength; i >1 ; i--){
y= (y + (Float.parseFloat(atoms[at oms.length -i])))*x;
}
y+= Float.parseFloat(atoms[atm length-1]) ;
System.out.println("y: " + y);
float z = 0.0f;
float gofrmX = x;
/*if (atmlength == 4) // 3rd degree
{
z = Float.parseFloat(atoms[ato ms.length- 1]) +
gofrmX*(
Float.parseFloat(atoms[ato ms.length- 2]) +
gofrmX*(
Float.parseFloat(atoms[ato ms.length- 3]) +
gofrmX*Float.parseFloat(at oms[atoms. length-4]) ));
}*/
if (atmlength == 3) // 2nd degree
{
y = Float.parseFloat(atoms[ato ms.length- 1]) +
gofrmX*(
Float.parseFloat(atoms[ato ms.length- 2]) +
gofrmX*Float.parseFloat(at oms[atoms. length-3]) );
}
System.out.println("y: " + y);
}
}
public static void main(String[] s){
String atoms[] = {"1","2","3"};
//String atoms[] = {"1","2","3", "4"};
int atmlength = atoms.length;
float x = 0.5f;
float y = 0.0f;//Float.parseFloat(at
for(int i = atmlength; i >1 ; i--){
y= (y + (Float.parseFloat(atoms[at
}
y+= Float.parseFloat(atoms[atm
System.out.println("y: " + y);
float z = 0.0f;
float gofrmX = x;
/*if (atmlength == 4) // 3rd degree
{
z = Float.parseFloat(atoms[ato
gofrmX*(
Float.parseFloat(atoms[ato
gofrmX*(
Float.parseFloat(atoms[ato
gofrmX*Float.parseFloat(at
}*/
if (atmlength == 3) // 2nd degree
{
y = Float.parseFloat(atoms[ato
gofrmX*(
Float.parseFloat(atoms[ato
gofrmX*Float.parseFloat(at
}
System.out.println("y: " + y);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
expertmb,
Thanks for your further efforts.
It is near 2:30 am and will study your responses when I get up in the morning.
D3
Thanks for your further efforts.
It is near 2:30 am and will study your responses when I get up in the morning.
D3
will not be available, long weekend for me ,(festival in india) catch you on monday for further comments.
ASKER
Hi expertmb ,
I have pursued this matter further
what was the former lines of coding in my work at
https://www.experts-exchange.com/questions/21131187/Automating-a-formula.html
.........
while (gofrmX <= gotoX )
{
if (atmlength == 3) // 2nd degree
{
y = Float.parseFloat(atoms[ato ms.length- 1]) +
gofrmX*(Float.parseFloat(a toms[atoms .length-2] ) +
gofrmX*Float.parseFloat(at oms[atoms. length-3]) );
}
if (atmlength == 4) // 3rd degree
{
y = Float.parseFloat(atoms[ato ms.length- 1]) +
gofrmX*(Float.parseFloat(a toms[atoms .length-2] ) +
gofrmX*(Float.parseFloat(a toms[atoms .length-3] ) +
gofrmX*Float.parseFloat(at oms[atoms. length-4]) ));
}
System.out.print("Value for y is " + y);
if( y < 0 ){
...........
the new replacement will be:
........
while (gofrmX <= gotoX )
{
y = 0;
float yC = Float.parseFloat(atoms[ato ms.length- 1]);// constant term
System.out.println ("Constant term "+ yC);
for(int i = atmlength; i >1 ; i--){
y = (y + (Float.parseFloat(atoms[at oms.length -i])))*gof rmX;
}
y= y + yC; // adding in the constant term
System.out.print ("total y = "+ y);
if( y < 0 ){
........
I am now able to do any number set of terms (well, maybe), thanks to you.
I am sure that this whole problem and revisions will not buy anyone a cup of coffee at any restaurant
Delphi3
I have pursued this matter further
what was the former lines of coding in my work at
https://www.experts-exchange.com/questions/21131187/Automating-a-formula.html
.........
while (gofrmX <= gotoX )
{
if (atmlength == 3) // 2nd degree
{
y = Float.parseFloat(atoms[ato
gofrmX*(Float.parseFloat(a
gofrmX*Float.parseFloat(at
}
if (atmlength == 4) // 3rd degree
{
y = Float.parseFloat(atoms[ato
gofrmX*(Float.parseFloat(a
gofrmX*(Float.parseFloat(a
gofrmX*Float.parseFloat(at
}
System.out.print("Value for y is " + y);
if( y < 0 ){
...........
the new replacement will be:
........
while (gofrmX <= gotoX )
{
y = 0;
float yC = Float.parseFloat(atoms[ato
System.out.println ("Constant term "+ yC);
for(int i = atmlength; i >1 ; i--){
y = (y + (Float.parseFloat(atoms[at
}
y= y + yC; // adding in the constant term
System.out.print ("total y = "+ y);
if( y < 0 ){
........
I am now able to do any number set of terms (well, maybe), thanks to you.
I am sure that this whole problem and revisions will not buy anyone a cup of coffee at any restaurant
Delphi3
>>I am sure that this whole problem and revisions will not buy anyone a cup of coffee at any restaurant
???
???
ASKER
expertmb,
Thanks to you I now have the formula. Your efforts are signinficant to me and I appreciate it.
My remark about the cup of coffee at a restaurant is an expression that means: for the average man in the street, I could offer him my Java program and he would more that likely react by saying "so what, is this program important to my life? and if it is I will buy you a cup of coffee at the restaurant". More than likely I could not convince him.
Again many thanks to you. You should have the points and the grade.
Delphi3
Thanks to you I now have the formula. Your efforts are signinficant to me and I appreciate it.
My remark about the cup of coffee at a restaurant is an expression that means: for the average man in the street, I could offer him my Java program and he would more that likely react by saying "so what, is this program important to my life? and if it is I will buy you a cup of coffee at the restaurant". More than likely I could not convince him.
Again many thanks to you. You should have the points and the grade.
Delphi3
ASKER
expertmb,
sorry for the spelling error:
signinficant is misspelled above and should be "significant" meanining the same as important or having value.
D3
sorry for the spelling error:
signinficant is misspelled above and should be "significant" meanining the same as important or having value.
D3
Dear Delphi3,
thanks for the comments. you took my comment(???) seriously, if the comment hurt really sorry for that.
mb ...
thanks for the comments. you took my comment(???) seriously, if the comment hurt really sorry for that.
mb ...
ASKER
expertmb,
the answer is that it did not hurt. I am very concerned that you understood me with the correct meaning.
This cross cultural thing is very important to me and I thought after the "???" you deserved an better explanation.
Sometimes thoughts come into my head, and out on to the screen too fast. I should run my thoughts into the cross cultural filter. As you can see I am running that filter now :)
So I am a happy person.
D3
the answer is that it did not hurt. I am very concerned that you understood me with the correct meaning.
This cross cultural thing is very important to me and I thought after the "???" you deserved an better explanation.
Sometimes thoughts come into my head, and out on to the screen too fast. I should run my thoughts into the cross cultural filter. As you can see I am running that filter now :)
So I am a happy person.
D3
:-)
mb...
mb...
y+= Float.parseFloat(atoms[ato
}