Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Sum value' topicStudent Support Forum > General > Archives > "Sum value"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
09/04/12 10:41pm

Is this anything like what you are looking for?

In[1]:= (*fromStringPercent*)
fSP[s_]:=ToExpression[StringReplace[s,"%"->"/100"]];
(*toStringPercent*)
tSP[n_]:=ToString[n*100]<>"%";

a=1;
e1=Which[a==1,"20%",a≠1,"0%"];
e2=Which[a==1,"20%",a≠1,"0%"];
tSP[fSP[e1]+fSP[e2]]

Out[6]= 40%

In[7]:= a=2;
e1=Which[a==1,"20%",a≠1,"0%"];
e2=Which[a==1,"20%",a≠1,"0%"];
tSP[fSP[e1]+fSP[e2]]

Out[10]= 0%

URL: ,

Subject (listing for 'Sum value')
Author Date Posted
Sum value chuck 09/04/12 11:14am
Re: Sum value Bill Simpson 09/04/12 10:41pm
Re: Sum value chuck 09/05/12 11:37am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic