correction in code required...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

correction in code required...

sohini dhar-2
Hi,
I have come down to this program...But I want my method to return the new sum every 45 tick count interval. Thats not happening here.Kindly help me someone with this.

public class houses
{

double[] con_app =new double[5];
{
for(int k=0;k<5;k++)
{
con_app[k] = RandomHelper.nextIntFromTo(50, 500);
System.out.println("con="+con_app[k]);
}
}
double[] c=new double[5];
int[] state_app = new int[5];
{
for(int i=0;i<5;i++)
{
state_app[i]=RandomHelper.nextIntFromTo(0, 1);
System.out.println("state"+state_app[i]);
}
}
@ScheduledMethod(start=0,interval=45,priority=ScheduleParameters.FIRST_PRIORITY)
public double getconsumption()
{
double sum = 0;
for(int j=0;j<5;j++)
{
if(state_app[j]==1)
{
c[j]=con_app[j];
}
else
{
c[j]=0;
}
//System.out.println("c"+c[j]);
//System.out.println("sum"+sum);
}
for(int k=0;k<5;k++)
{
sum=sum+c[k];
}
return sum;
}

Thanks,
Sohini.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: correction in code required...

srcnick
Is the code that fills con_app and state_app supposed to be in a constructor? What sort of error do get when you run this?

> On Jun 2, 2017, at 2:38 AM, sohini dhar <[hidden email]> wrote:
>
> Hi,
> I have come down to this program...But I want my method to return the new sum every 45 tick count interval. Thats not happening here.Kindly help me someone with this.
>
> public class houses
> {
>
> double[] con_app =new double[5];
> {
> for(int k=0;k<5;k++)
> {
> con_app[k] = RandomHelper.nextIntFromTo(50, 500);
> System.out.println("con="+con_app[k]);
>
> }
> }
>
> double[] c=new double[5];
>
>
> int[] state_app = new int[5];
> {
> for(int i=0;i<5;i++)
> {
> state_app[i]=RandomHelper.nextIntFromTo(0, 1);
> System.out.println("state"+state_app[i]);
> }
> }
>
>
>
>
>
> @ScheduledMethod(start=0,interval=45,priority=ScheduleParameters.FIRST_PRIORITY)
> public double getconsumption()
> {
> double sum = 0;
> for(int j=0;j<5;j++)
> {
> if(state_app[j]==1)
> {
> c[j]=con_app[j];
> }
> else
> {
> c[j]=0;
> }
> //System.out.println("c"+c[j]);
>
> //System.out.println("sum"+sum);
>
> }
> for(int k=0;k<5;k++)
> {
> sum=sum+c[k];
> }
> return sum;
>
>
> }
>
> Thanks,
> Sohini.
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...