Array headache

I am trying to create a histogram using 2 arrays. One stores the user input and the other categorizes the input into 10 different "buckets" i.e. 1 - 10; 11 - 20, etc.
I almost have it but when I print out the histogram I get a really large number for the first category (1 - 10). It looks like I'm getting a value that is some derivation of the array.length and I have no clue why.
Does anyone have an idea what I could do to get the first category to work. The keyboard class was written by the authors of the textbook we're using.
here is what I have so far:
import cs1.Keyboard;
public class Histogram
public static void main (String[] args)
final int MIN = 1;
final int MAX = 100;
int input = 0;
int index = 0;
float category = 0;
float[] numbers = new float[1000];
int[] frequency = new int[10];
while (input != -1 && (index < numbers.length))     
System.out.print ("Enter a number between " + MIN + " and " + MAX + " (-1 to summarize): ");
input = Keyboard.readInt();
if (input != -1 && (input < MIN || input > MAX))
System.out.println ("The number you entered an invalid value!");
System.out.println ("Please enter a value between " + MIN + " and " + MAX);
else
numbers[index] = input;
index++;     
if (input == -1)
for (int i = 0; i < numbers.length; i++)
if ((numbers[i] % 10 == 0) && (numbers[i] / 10 != 10))
//category = ((numbers[i] / 10) - 1);
category = (numbers[i] / 10);
else
if (numbers[i] / 10 == 10)
category = 9;
else
if (numbers[i] / 10 < 1)
category = 0;
else
category = numbers[i] / 10;
frequency[(int)category] = frequency[(int)category] + 1;
for (int i = 0; i < frequency.length; i++)
System.out.println (i + "1 - " + (i + 1) + "0 | " + frequency);

Try to change the output section like this:
From:
for (int i = 0; i < frequency.length; i++)
System.out.println (i + "1 - " + (i + 1) + "0 | " + frequency[ i ]);
To:
int k=1;
for (int i = 0; i < frequency.length; i++) {
     String out=""+k;
     if (out.length()<2) out=" "+out;
     k+=10;
     String tmp=""+(k-1);
     while (tmp.length()<3) tmp=" "+tmp;
     out+=" - "+tmp+" | ";
     for (int j=0;j<frequency[ i ];j++) out+="*";
     System.out.println (out);
};o)
V.V.

Similar Messages

  • New user with an  massive array/string headache

    Working with a large (365 source files, 65 mxml files) SDK 3.6.0 project in FB 4.5 and continually get :
    Resource
    Path
    Location
    Description
    Type
    TB4.mxml
    /the0bot_1/src/the0bot/gui
    line 1
    1067: Implicit coercion of a value of type String to an unrelated type Array.
    Flex Problem
    TB4.mxml
    /the0bot_1/src/the0bot/gui
    line 1
    1184: Incompatible default value of type String where Array is expected.
    Flex Problem
    It is a very strange error, as you can see, line #1 is my language declaration!
    <?xml version="1.0" encoding="utf-8"?>
    This error is virtually non-removable.  It usually attaches to a component, or an ArrayCollection, and even if I delete the accused violator, the error will find a new point of attachment.?  This is the only page in the project that involves two-way data binding.  I had at first attributed the error to a yahoo.astra.com timestepper drop-in, but even rebuilding the page without that component does not remedy the trouble....
    Any help at this point would be appreciated, There are countless hours invested in the project and this has been a hold-up for several days now. 
    Thank you.

    Nothing had changed project-wise originally. I am simply adding a new mxml component to a perfectly good runnable project. I have since moved my workspace twice to a clean folder, and if  I remove the module everything is back to normal.
    I do notice that it won't show up if I have a normal error (i.e add a visual component but have not added code yet or forget a brace or such) but then when I clear the last error and validate, the cursor will jump to the top of the page mmediately.
    currently the errors are
    Resource
    Path
    Location
    Description
    Type
    TB4.mxml
    /the0bot_1/src/the0bot/gui
    line 296
    1067: Implicit coercion of a value of type String to an unrelated type Array.
    Flex Problem
    TB4.mxml
    /the0bot_1/src/the0bot/gui
    line 296
    1184: Incompatible default value of type String where Array is expected.
    Flex Problem
    (they have moved off the header to the reinstalled numberformatter)
    the code:
    Some may seem a little unconventional, but I have been getting strange errors like 
    Resource
    Path
    Location
    Description
    Type
    TB4.mxml
    /the0bot_1/src/the0bot/gui
    line 222
    1105: Target of assignment must be a reference value.
    Flex Problem
    which is why the 2 " tbean(t) = n; " lines are commented out.     ( tbean = object, t = string, n = number)???
    (all the bindings are an attempt at elimination....)
    <?xml version="1.0" encoding="utf-8"?>
         <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
                             xmlns:gui="the0bot.gui.*"
                             width="418" height="289">
              <mx:Script>
                        <![CDATA[
                                  import com.evony.common.beans.*;
                                  import com.evony.common.constants.*;
                                  import com.google.analytics.debug._Style;
                                  import flash.events.*;
                                  import flash.utils.*;
                                  import mx.collections.ArrayCollection;
                                  import mx.controls.Button;
                                  import mx.events.*;
                                  import mx.events.ItemClickEvent;
                                  import mx.events.PropertyChangeEvent;
                                  import mx.utils.ObjectUtil;
                                  import the0bot.common.*;
                                  import the0bot.event.CityManagerUpdateEvent;
                                  import the0bot.management.*;
                                  import the0bot.management.CityManager;
                                  import the0bot.player.*;
                                  import the0bot.scripts.*;
                                  private var cityManager:CityManager;
                                  private var city:CityState;
                                  public var _THE0BOT:String = "the0bot";
                                  public var the0bot:Boolean;
                                  public static const yes:Boolean = true;
                                  public static const no:Boolean = false;
                                  public static const zero:int = 0;
                                  public static const resource:Array = ("food", "wood", "stone", "iron", "gold");
                                  [Bindable]public var text:String;
                                  [Bindable]public var value:Number;
                                  [Bindable]public var tb2Heroes:ArrayCollection;
                                  [Bindable]public var tb2Troops:ArrayCollection;
                                  [Bindable]public var tb3Queue:ArrayCollection;
                                  [Bindable]public var tb2Resources:ArrayCollection;
                                  [Bindable]public var tb2Cities:ArrayCollection;
                                  [Bindable]public var selectedIndex:int;
                                  [Bindable]public var selectedCity:String;
                                  [Bindable]public var selectedHero:String;
                                  [Bindable]public var selectedtb3:String;
                                  // Rom
                                  public function init(citymanager:CityManager,City:CityState) : void {
                                            cityManager = citymanager;
                                            city=City;
                                            the0bot = (this.cityManager.getConfig(_THE0BOT, 0));
                                            resettb2Data();
                                            listCities;
                                            cityManager.addEventListener(CityManagerUpdateEvent.TYPE, onUpdate);
                                            Context.getInstance().addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, onContexthandler);
                                            Context.getInstance().addEventListener(CityManagerUpdateEvent.TYPE, onUpdate);
                                            Refresh();
                                  public function unInit() : void {
                                            if (cityManager.hasEventListener(CityManagerUpdateEvent.TYPE))
                                                      cityManager.removeEventListener(CityManagerUpdateEvent.TYPE, onUpdate);
                                            if (Context.getInstance().hasEventListener(CityManagerUpdateEvent.TYPE))
                                                      Context.getInstance().removeEventListener(CityManagerUpdateEvent.TYPE, onUpdate);
                                            cityManager = null;
      public function Refresh() : void {
                                            this.callLater(updateHeroes);
                                  [Bindable]private var travelTime:Number;
                                  [Bindable]private var campTime:Number;
                                  private function onContexthandler(event:PropertyChangeEvent) : void
                                            campTime = (Number(campMinutes.text)* 60000) + campSeconds.value * 1000;
                                            var t =(Utils.getServerTime() + travelTime + campTime)as Date;
                                            _arriveClock.text = TFseconds.format(t);
                                            (xSpin.value >= 800)? xSpin.value=0 : (xSpin.value <= -1)? xSpin.value = 799 :t=null;
                                            (ySpin.value >= 800)? ySpin.value=0 : (ySpin.value <= -1)? ySpin.value = 799 :t=null;
                                  private function onUpdate(event:CityManagerUpdateEvent) : void {
                                            if (event.CastleId == cityManager.id || event.CastleId == -1) {
                                                      switch (event.UpdateType) {
                                                                case CityManagerUpdateEvent.TROOPS:
                                                                case CityManagerUpdateEvent.PRODUCTION:
                                                                          Refresh();
                                                                          break;
                                  private function updateHeroes():void
                                            if (heroMenu.selectedIndex != zero) return;
                                            tb2Heroes.disableAutoUpdate();
                                            tb2Heroes = new ArrayCollection;
                                            for each (var hero:HeroBean in cityManager.heroes){
                                                      if (hero.isIdle == yes){
                                                                var obj:Object = new Object;
                                                                obj.label = hero.name;
                                                                tb2Heroes.addItem(obj);
                                            obj = {label:"any"};
                                            tb2Heroes.addItemAt(obj, 0);
                                            obj = {label:"none"};
                                            tb2Heroes.addItemAt(obj, 0);
                                            tb2Heroes.enableAutoUpdate();
                                            heroMenu.selectedIndex = zero;
                                  public function resettb2Troops() : void
                                            var tb2:Array = new Array();
                                            for (var t:int = 0; t < TroopType.justTroopIntNames.length-1; t++ )
                                                      tb2[t].label = TroopType.justTroopAbbr[t];
                                                      tb2[t].data = 0;
                                                      tb2[t].type = TroopType.justTroopIntNames[t];
                                            tb2Troops = new ArrayCollection(tb2);
                                  private function resettb2Resources():void
                                            var tb2:Array = new Array;
                                            for (var i:int = 0; i < resource.length-1; i++);
                                                      tb2.label = resource[i].charAt(0) + ":";
                                                      tb2.data = 0;
                                                      tb2.type = resource[i];
                                            tb2Resources = new ArrayCollection(tb2);
                                  private function listCities():void{
                                            tb2Cities = new ArrayCollection;
                                            for each (var gcity:CityState in Context.getInstance().cities){
                                                      var obj:Object = new Object;
                                                      obj.label = gcity.cityManager.castle.name;
                                                      obj.id = gcity.cityManager.castle.fieldId;
                                                      (obj.id == this.cityManager.castle.fieldId) ? tb2Cities.addItemAt(obj, zero) : tb2Cities.addItem(obj);
                                  private function resettb2Data():void
                                            resettb2Troops()
                                            resettb2Resources()
                                            updateHeroes();
                                            listCities();
                                  public function doesHaveEnsign(): Boolean {
                                            var player:* = Context.getInstance().Player;
                                            for each (var item:* in player.itemsArray) {
                                                      if (item.id == null) continue;
                                                      if (item.id == "player.troop.1.a") return true;
                                            return false;
                                  protected function campSwitchClick(event:MouseEvent):void
                                            /* if (campSwitch.selected = yes) arriveSwitch.selected = no;
                                            else {campMinutes.text = "0";
                                                      campSeconds.value=0;
                                  protected function arriveSwitchClick(event:MouseEvent):void
                                            if (arriveSwitch.selected = yes){
                                                      campSwitch.selected = no;
                                                      travelTime=0;
                                            else travelTime = getArmyMarchTime();
                                  public function tb2troopsToBean():TroopBean{
                                            var tbean = new TroopBean;
                                            var tb2:Array = tb2Troops.toArray()
                                            for (var i:int = 0; i < tb2.length-1; i++ )
                                            var n:Number = tb2[i].data;
                                            var t:String = tb2[i].type;
                                            //tbean(t) = n;
                                            return tbean;
                                  public function tb2resToBean():ResourceBean{
                                            var tbean = new ResourceBean;
                                            var tb2:Array = tb2Resources.toArray();
                                            for (var i:int = 0; i < tb2.length-1; i++ )
                                                      var n:Number = tb2[i].data;
                                                      var t:String = tb2[i].type;
                                                      //tbean(t) = n;
                                            return tbean;
                                  private  function spinCoordsString():String
                                            return xSpin.value + "," + ySpin.value;
                                  private  function missionTypeIndex():int
                                            var s:int=marchMenu.selectedIndex+1;
                                            if (s==4)s++;
                                            return s;
                                  private  function spinnersToFieldID():int{
                                            return (int(ySpin.value)*800 + int(xSpin.value));
                                  private  function fieldIDtoSpinners(fieldID:int):void
                                            xSpin.value = Map.getX(fieldID);
                                            ySpin.value = Map.getY(fieldID);
                                  public function getArmyMarchTime():Number{
                                            return cityManager.getAttackTravelTime(this.cityManager.id, spinnersToFieldID(), tb2troopsToBean(), missionTypeIndex());
                                  protected function xySpin_changeHandler():void
                                  protected function sendSwitchClick(event:MouseEvent):void
                                            var t:TroopBean = tb2troopsToBean();
                                            var r:ResourceBean = tb2resToBean();
                                            var camp:String = "";
                                            var time:String = campMinutes.text + ":" + campSeconds.textSnapshot;
                                            camp += (arriveSwitch.selected) ? "@:" + time : (campSwitch.selected) ? "c:" + time : "";
                                            if (!useEnsignSwitch.selected == yes)
                                                      this.city.sendTroops(spinCoordsString(), TroopType.troopBeanToString(t,","), missionTypeIndex(), heroMenu.text, r, camp);
                                            else this.city.sendBigTroops(spinCoordsString(), TroopType.troopBeanToString(t,","), missionTypeIndex(), heroMenu.text, r, camp);
                                            heroMenu.selectedIndex = zero;
                                            updateHeroes();
                                  protected function citycloseHandler(event:FlexEvent):void
                                            for each (var gcity:CityState in Context.getInstance().cities){
                                                      if (gcity.cityManager.castle.name == cityMenu.selectedLabel){
                                                                fieldIDtoSpinners(gcity.cityManager.castle.fieldId);
                                  private function herocloseHandler(event:Event):void {
                                            selectedHero = ComboBox(event.target).selectedItem.label;
                        ]]>
              </mx:Script>
              <mx:DateFormatter id="TFseconds" formatString="J:NN:SS"/>
              <mx:HBox width="415" height="288" horizontalGap="5" horizontalScrollPolicy="off" paddingTop="5"
                                   verticalScrollPolicy="off">
                        <mx:VBox width="277" height="280" horizontalAlign="center" horizontalScrollPolicy="off"
                                             verticalGap="4" verticalScrollPolicy="off">
                                  <mx:HBox x="0" y="0" height="276" horizontalGap="5" paddingLeft="5" paddingTop="3">
                                            <mx:VBox height="267" horizontalScrollPolicy="off" paddingTop="5" verticalGap="4"
                                                                 verticalScrollPolicy="off">
                                                      <mx:HBox id="troopCountBox" width="125" height="25" borderColor="#2B1296"
                                                                           borderStyle="solid" borderThickness="2" cornerRadius="5"
                                                                           horizontalAlign="center" horizontalGap="0" horizontalScrollPolicy="off"
                                                                           verticalScrollPolicy="off">
                                                                <mx:Label width="37" paddingTop="2" text="Army" textAlign="center"/>
                                                                <mx:Text width="70" paddingTop="2" text="125,000" textAlign="left"/>
                                                      </mx:HBox>
                                                      <mx:DataGrid id="table1" width="125" height="226" backgroundAlpha=".1"
                                                                                     backgroundColor="#EADFF2" borderColor="#400AAF" borderStyle="solid"
                                                                                     borderThickness="2" dataProvider="{tb2Troops}"
                                                                                     lockedColumnCount="2" lockedRowCount="12"
                                                                                     resizableColumns="false" rowHeight="20" selectionMode="singleCell"
                                                                                     showHeaders="false" sortableColumns="false"
                                                                                     variableRowHeight="false">
                                                                <mx:columns>
                                                                          <mx:DataGridColumn width="35" dataField="abbr" editable="false"
                                                                                                                      fontSize="10"/>
                                                                          <mx:DataGridColumn width="90" dataField="data" editable="true"
                                                                                                                      editorDataField="value" fontSize="10"
                                                                                                                      formatter="{nf}"
                                                                                                                      itemEditor="mx.controls.NumericStepper"/>
                                                                </mx:columns>
                                                      </mx:DataGrid>
                                            </mx:VBox>
                                            <mx:VBox width="131" height="268" horizontalAlign="center" paddingTop="5" verticalGap="4">
                                                      <mx:HBox width="125" height="25" borderColor="#2B1296" borderStyle="solid"
                                                                           borderThickness="2" cornerRadius="5" horizontalAlign="center" horizontalGap="0"
                                                                           horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                                                <mx:Label width="31" paddingLeft="0" paddingRight="0" paddingTop="2" text="Res."
                                                                                      textAlign="right"/>
                                                                <mx:Text width="80" paddingTop="2" text="999,999,999" textAlign="left"/>
                                                      </mx:HBox>
                                                      <mx:DataGrid id="table2" width="125" height="139" allowMultipleSelection="false"
                                                                                     backgroundAlpha=".1" backgroundColor="#DBE4F5" borderColor="#400AAF"
                                                                                     dataProvider="{tb2Resources}" lockedColumnCount="2" lockedRowCount="5"
                                                                                     resizableColumns="false" rowHeight="20" selectionMode="singleCell"
                                                                                     showHeaders="false" sortableColumns="false" variableRowHeight="false">
                                                                <mx:columns>
                                                                          <mx:DataGridColumn width="35" dataField="abbr" editable="false"
                                                                                                                      fontSize="10" headerText="Type" textAlign="right"/>
                                                                          <mx:DataGridColumn dataField="data" editable="true"
                                                                                                                      editorDataField="value" fontSize="10" formatter="nf"
                                                                                                                      headerText="Amt." textAlign="right">
                                                                                    <mx:itemEditor>
                                                                                              <mx:Component>
                                                                                                         <mx:NumericStepper doubleClickEnabled="true"
                                                                                                                                                    maximum="{resMax()}"
                                                                                                                                                    stepSize="1"/>
                                                                                              </mx:Component>
                                                                                    </mx:itemEditor>
                                                                          </mx:DataGridColumn>
                                                                </mx:columns>
                                                      </mx:DataGrid>
                                                      <mx:HBox horizontalScrollPolicy="off" verticalAlign="middle"
                                                                           verticalScrollPolicy="off">
                                                                <mx:Label width="33" height="19" text="Arr:" textAlign="right"/>
                                                                <mx:Text id="_arriveClock" width="76" height="21" paddingLeft="2" paddingTop="1"
                                                                                     text="00:00:00" textAlign="left"/>
                                                      </mx:HBox>
                                                      <mx:HBox width="84" horizontalGap="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                                                <mx:TextInput id="campMinutes" width="23" fontWeight="bold" maxChars="3"
                                                                                                 restrict="0-9" text="00" textAlign="right"/>
                                                                <mx:Text width="7" fontWeight="bold" selectable="false" text=":"
                                                                                     textAlign="right"/>
                                                                <mx:NumericStepper id="campSeconds" width="49" fontWeight="bold" maximum="59" value="" textAlign="left"/>
                                                      </mx:HBox>
                                                      <mx:ComboBox id="marchMenu" width="100" editable="false" fillColors="black,blue"
                                                                                     textAlign="center">
                                                                <mx:dataProvider>
                                                                          <mx:Array>
                                                                                    <mx:String>transport</mx:String>
                                                                                    <mx:String>reinforce</mx:String>
                                                                                    <mx:String>scout</mx:String>
                                                                                    <mx:String>attack</mx:String>
                                                                          </mx:Array>
                                                                </mx:dataProvider>
                                                      </mx:ComboBox>
                                            </mx:VBox>
                                  </mx:HBox>
                        </mx:VBox>
                        <mx:HBox width="125" height="280" borderColor="#400AAF" borderStyle="solid"
                                             borderThickness="2" cornerRadius="5" horizontalGap="3" horizontalScrollPolicy="off"
                                             paddingLeft="4" paddingTop="4" verticalScrollPolicy="off">
                                  <mx:VBox width="115" height="269" horizontalAlign="center" horizontalScrollPolicy="off"
                                                       verticalGap="5" verticalScrollPolicy="off">
                                            <mx:RadioButton id="useEnsignSwitch" width="65" label="Ensign"/>
                                            <mx:HBox width="100%" height="27" borderColor="#3F2AC1" borderStyle="solid"
                                                                 borderThickness="2" cornerRadius="5" horizontalAlign="center"
                                                                 verticalAlign="middle">
                                                      <mx:Button id="editSwitch" width="45" height="20" label="Edit" enabled="false"
                                                                             paddingLeft="1" paddingRight="1" toggle="true"/>
                                                      <mx:Button id="FMJSwitch" width="45" height="20" label="F.M.J."
                                                                             click="campSwitchClick(event)" enabled="false" paddingLeft="1"
                                                                             paddingRight="1" selected="true" toggle="true"/>
                                            </mx:HBox>
                                            <mx:ComboBox id="tb3Menu" width="100" dataProvider="{tb2Heroes}" editable="false"
                                                                           close="tb3closeHandler(event)" fillColors="black,blue" selectedIndex="0"
                                                                           textAlign="center">
                                            </mx:ComboBox>
                                            <mx:ComboBox id="cityMenu" width="100" dataProvider="{tb2Cities}" editable="false"
                                                                           close="citycloseHandler(event)" fillColors="black,blue" selectedIndex="0"
                                                                           textAlign="center">
                                            </mx:ComboBox>
                                            <mx:ComboBox id="heroMenu" width="100" dataProvider="{tb2Heroes}" editable="false"
                                                                           close="herocloseHandler(event)" fillColors="black,blue" selectedIndex="0"
                                                                           textAlign="center">
                                            </mx:ComboBox>
                                            <mx:HBox width="100" height="28" horizontalAlign="center" horizontalGap="0" paddingBottom="0"
                                                                 paddingLeft="0" paddingRight="0" paddingTop="0" verticalAlign="middle">
                                                      <mx:Label text="X:"/>
                                                      <mx:NumericStepper id="xSpin" width="55" change="xySpin_changeHandler(event)"
                                                                                                  maximum="800" minimum="-1" value="0"/>
                                            </mx:HBox>
                                            <mx:HBox width="100" height="28" horizontalAlign="center" horizontalGap="0"
                                                                 horizontalScrollPolicy="off" paddingBottom="0" paddingLeft="0" paddingRight="0"
                                                                 paddingTop="0" verticalAlign="middle" verticalScrollPolicy="off">
                                                      <mx:Label text="Y:"/>
                                                      <mx:NumericStepper id="ySpin" width="55" change="xySpin_changeHandler(event)"
                                                                                                  maximum="800" minimum="-1" value="0"/>
                                            </mx:HBox>
                                            <mx:HBox width="108" height="26" borderColor="#3F2AC1" borderStyle="solid"
                                                                 borderThickness="2" cornerRadius="5" horizontalAlign="center"
                                                                 horizontalScrollPolicy="off" verticalAlign="middle" verticalScrollPolicy="off">
                                                      <mx:Button id="sendSwitch" width="45" height="22" label="Send" borderColor="#60C592"
                                                                             click="sendSwitchClick(event)" paddingLeft="1" paddingRight="1"/>
                                                      <mx:Button id="clearSwitch" width="54" height="22" label="Clear"
                                                                             click="clearSwitch_clickHandler(event)"/>
                                            </mx:HBox>
                                            <mx:HBox width="100%" height="27" borderColor="#3F2AC1" borderStyle="solid"
                                                                 borderThickness="2" cornerRadius="5" horizontalAlign="center"
                                                                 verticalAlign="middle">
                                                      <mx:Button id="arriveSwitch" width="45" height="20" label="Arrive" enabled="true"
                                                                             paddingLeft="1" paddingRight="1" toggle="true"/>
                                                      <mx:Button id="campSwitch" width="45" height="20" label="Camp"
                                                                             click="campSwitchClick(event)" enabled="true" paddingLeft="1"
                                                                             paddingRight="1" selected="true" toggle="true"/>
                                            </mx:HBox>
                                  </mx:VBox>
                        </mx:HBox>
              </mx:HBox>
    </mx:Canvas>

  • Reading characters from a text file into a multidimensional array?

    I have an array, maze[][] that is to be filled with characters from a text file. I've got most of the program worked out (i think) but can't test it because I am reading my file incorrectly. However, I'm running into major headaches with this part of the program.
    The text file looks like this: (It is meant to be a maze, 19 is the size of the maze(assumed to be square). is free space, # is block, s is start, x is finish)
    This didn't paste evenly, but thats not a big deal. Just giving an idea.
    19
    5..................
    And my constructor looks like follows, I've tried zillions of things with the input.hasNext() and hasNextLine() to no avail.
    Code:
    //Scanner to read file
    Scanner input = null;
    try{
    input = new Scanner(fileName);
    }catch(RuntimeException e) {
    System.err.println("Couldn't find the file");
    System.exit(0);
    //Set the size of the maze
    while(input.hasNextInt())
    size = input.nextInt();
    //Set Limits on coordinates
    Coordinates.setLimits(size);
    //Set the maze[][] array equal to this size
    maze = new char[size][size];
    //Fill the Array with maze values
    for(int i = 0; i < maze.length; i++)
    for(int x = 0; x < maze.length; x++)
    if(input.hasNextLine())
    String insert = input.nextLine();
    maze[i][x] = insert.charAt(x);
    Any advice would be loved =D

    Code-tags sometimes cause wonders, I replaced # with *, as the code tags interprets # as comment, which looks odd:
    ******...*.........To your code: Did you test it step by step, to find out about what is read? You could either use a debugger (e.g., if you have an IDE) or system outs to get a clue. First thing to check would be, if the maze size is read correctly. Further, the following loops look odd:for(int i = 0; i < maze.length; i++) {
        for(int x = 0; x < maze.length; x++) {
            if (input.hasNextLine()) {
                String insert = input.nextLine();
                maze[x] = insert.charAt(x);
    }Shouldn't the nextLine test and assignment be in the outer loop? And assignment be to each maze's inner array? Like so:for(int i = 0; i < maze.length; i++) {
        if (input.hasNextLine()) {
            String insert = input.nextLine();
            for(int x = 0; x < insert.size(); x++) {
                maze[i][x] = insert.charAt(x);
    }Otherwise, only one character per line is read and storing a character actually should fail.

  • Textcolor change of a single element in an array of clusters

    hi, right now I rewrite some code for a more flexible approach in the future.
    One special VI causes me some serious headache right now, I need to display a flexible number of versions which will be determined on the fly with the hardware avaible. Till now it were only some controls and a fixed amount of versions to expect.
    To adress this issue I created an array of cluster in which each cluster stands for all data of the version. No problem works just fine.
    The main problem is, that previously new versions (different from the last value) would be bright red while the others remain black.
    Something an array of cluster doesnt support
    I could overlay the text with a picture control and "paint" the text in the different colours as a workaround, but I would prefer not to.
    Do you know any other more elegant way to deal with this issue?

    Create two transparent string indicators on top of each other, one with a different font color. Make one an empty string and the other the desired value. Swap the values to get the "other" display.
    LabVIEW Champion . Do more with less code and in less time .

  • Variable size array output from dynamic dispatch class method on FPGA

    I have a Parent class on the FPGA that will serve as a template/framework for future code that will be developed. I had planned on creating a child class and overriding a couple methods. The child class constant would be dropped on the block diagram so the compiler wouldn't have any trouble figuring out which method (parent's or child's) should be used (i.e. the parent's method will never actually be used and won't be compiled with the main code). The output of one of the methods is an array. This array will have a different size depending on the application. I defined the array size as variable. In the child method, there is no question about the size of the array so the compiler should be able to figure it out. However, when I try to compile, I get an error about the array size. I can't figure out any way around it. Any thought would be greatly appreciated! 
    Thanks, Patrick
    Solved!
    Go to Solution.
    Attachments:
    FPGA Test.zip ‏1194 KB

    Wait what?
    Can we use dynamic dispatch VIs on FPGA?  Really?  I was completely unaware of this.  Obviously the dependencies need to be constant and known at compile time but...... This would have saved me a lot of headaches in the last few months.
    Since which LV version is this supported?
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Need Help with Arrays/Text

    I'm trying to create a flash program that uses it's own code to send and create images. Each square has a colour and that colour gets added into the array. A black, then grey, then white is:
    filecode = ["Bl", "Gr", "Wh"];
    That works fine, but when I try to paste it into an Input text box it will only fill in the first part of the array.
    filecode = ["Bl,Gr,Wh"];
    So the program has NO idea what I want.
    The only ways I can think of fixing this is by putting in 402 text boxes to suit every box...But every one of them needs a Variable Name.
    Or by sending the information straight into the array. But this way you are just looking at what you just drew, and that is not at ALL practical.
    Helping me with this headache will be greatly apprectiated.
    FlashDrive100.

    If you can explain the first part of your posting it might become a little clearer what you are trying to do and what isn't working... particularly this...
    " when I try to paste it into an Input text box it will only fill in the first part of the array."
    I can't speak for anyone else, but at this point, I share your file's problem... not knowing what you want.

  • How do you choose a particular Channel from an Advise.vi to perform an Array Max & Min.vi on that particular channel only?

    Reading all the channels for a FP-AI-100 through an Advise.vi but I need to read the Max & Min from channels 0 & 1. How is this done?
    Thanks

    The easiest way is to use two copies of the Index Array function. You would wire the output from FP Advise.vi to the n-dimension array input of both Index Array functions. For channel 0, you would use the an index value of 0 (on the first Index Array) and for channel 1, you would use an index value of 1 (on the second Index Array). Alternatively, the Index Array function is what is called a growable array function, you can drag the bottom of the node downwards, adding outputs. In this case, you can set it for two outputs and only use one copy of the Index Array.
    Considering that you are relatively new to FieldPoint and LabVIEW, I recommend that you consider using the FP Read.vi instead of the FP Advise.vi. The FP Advise.vi is a more advanced version of the
    FP Read.vi and has more "gotcha's" in its use. To save yourself some debugging headaches it may be easier to use the FP Read.vi. The single biggest difference in coding between the two is that an FP Advise.vi in a loop, automatically times the loop, whereas an FP Read.vi in a loop requires a timer such as Wait Until Next ms Multiple.vi.
    Regards,
    Aaron

  • How  to Pass String array from Java to PL/SQL  and this use in CURSOR

    hi,
    I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
    This array containing like (SYMPTOM ) to be returned from the java to the
    pl/sql (I am not querying the database to retrieve the information).
    I cannot find an example on this. I will give the PL/SQL block
    create or replace procedure DISEASE_DTL<*** String Array ***> as
    v_SYMPTOM number(5);
    CURSOR C1 is
    select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
    where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
    group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
    order by a.DISEASE_NAME ;
    begin
    for C1rec IN C1 loop
    select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
    insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
    values (SL_ID_SEQ.nextval,
    C1rec.DISEASE_NAME,
    (4/v_SYMPTOM), --------**** 4 is no of array element (n)************
    (1-(4/v_SYMPTOM)));
    end loop;
    commit;
    end DISEASE_DTL;
    Please give the proper solution and step ..
    Thanking you,
    Asish

    I've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
    http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/

  • I need help with 2 arrays

    I need help with this portion of my program, it's supposed to loop through the array and pull out the highest inputted score, currently it's only outputting what is in studentScoreTF[0].      
    private class HighScoreButtonHandler implements ActionListener
               public void actionPerformed(ActionEvent e)
              double highScore = 0;
              int endScore = 0;
              double finalScore = 0;
              String tempHigh;
              String tempScore;
              for(int score = 0; score < studentScoreTF.length; score++)
              tempHigh = studentScoreTF[score].getText();
                    tempScore = studentScoreTF[endScore].getText();
              if(tempHigh.length() <  tempScore.length())
                   highScore++;
                   finalScore = Double.parseDouble(tempScore);
             JOptionPane.showMessageDialog(null, "Highest Class Score is: " + finalScore);This is another part of the program, it's supposed to loop through the student names array and pull out the the names of the students with the highest score, again it's only outputting what's in studentName[0].
         private class StudentsButtonHandler implements ActionListener
               public void actionPerformed(ActionEvent e)
              int a = 0;
              int b = 0;
              int c = 0;
              double fini = 0;
              String name;
              String score;
              String finale;
              String finalName = new String();
              name = studentNameTF[a].getText();
              score = studentScoreTF.getText();
              finale = studentScoreTF[c].getText();
              if(score.length() < finale.length())
                   fini++;     
                   name = finalName + finale;
         JOptionPane.showMessageDialog(null, "Student(s) with the highest score: " + name);
                   } Any help would be appreciated, this is getting frustrating and I'm starting to get a headache from it, lol.
    Edited by: SammyP on Oct 29, 2009 4:18 PM
    Edited by: SammyP on Oct 29, 2009 4:19 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Heres a working example:
    class Compare {
        public int getHighest(int[] set) {
            int high = set[0];
            for(int i = 0; i < set.length; i++) {
                if(set[i] > high) {
                    high = set;
    return high;

  • Java Lottery - relating arrays to each other

    Hello all and thank you for taking the time to read my problem.
    I am trying to create a program that asks the user for their name, then how man tickets they would like, then they enter 6 numbers for each ticket.
    The maximum amount of 6 number tickets that can be bought is 20.
    So for example user1 could get three tickets, user2 could get 10 tickets and user3 could get 7 tickets (20 in total).
    My main headache is how to relate the ticket numbers entered with the persons username.
    I assume that if user1 gets three tickets these are stored in an array [6] [20] but then when user2 puts their lines on how do I print out at the end who has which tickets?
    Also the maximum array size for tickets is [6] [20]...but what if only one user buys 3 tickets and does not use up the remaining 17 tickets, does this affect how I define the array?
    Thanks again, all help welcome!

    This is sort of what they were talking about, this is an object oriented approach.
    There should be no 2D arrays, just arrays of Objects that contain data about themselves or perhaps more Objects.
    Try to make your code look more like this.
    import java.util.*;
    public class Lottery {
        private LinkedList<Person> line = new LinkedList<Person>();
        public Person nextInLine() {
            line.add( new Person() );
            return line.getLast();
        public void showTicketsPurchased() {
            System.out.println( "\nTickets Purchased:");
            for( Person p: line ) {
                p.showTicketsPurchased();
        class Person {
            private LinkedList<Ticket> tickets= new LinkedList<Ticket>();
            void buyTicket( int num1, int num2, int num3, int num4, int num5, int num6 ) {
                try {
                    tickets.add( Ticket.sellTicket( num1, num2, num3, num4, num5, num6 ) );
                    System.out.println( "Bought Ticket: " + tickets.getLast() );
                } catch (NoSuchElementException nsee) {
                    System.out.println( nsee.getMessage() );
                    System.out.println( "Could not buy ticket, it's sold out");
            public void showTicketsPurchased() {
                for ( Ticket t: tickets ) {
                    System.out.println( t );
        public static void main( String[] args ) {
            Lottery lottery = new Lottery();
            Person servingThisPerson;
            //First person in line
            servingThisPerson = lottery.nextInLine();
            servingThisPerson.buyTicket( 1,2,3,4,5,6 );
            servingThisPerson.buyTicket( 2,3,4,5,6,7 );
            //Second person in line
            servingThisPerson = lottery.nextInLine();
            servingThisPerson.buyTicket( 10, 20, 30, 40, 50, 60 );
            servingThisPerson.buyTicket( 20, 30, 40, 50, 60, 70 );
            lottery.showTicketsPurchased();
    import java.util.*;
    public class Ticket {
        public static final int MAX_NUM_TICKETS = 20;
        private static int numTicketsSold = 0;
        private int[] numbers;
        private Ticket( int num1, int num2, int num3, int num4, int num5, int num6 ) {
            numbers = new int[]{ num1, num2, num3, num4, num5, num6 };
            numTicketsSold++;
        public static Ticket sellTicket( int num1, int num2, int num3, int num4, int num5, int num6 ) {
            if( numTicketsSold < MAX_NUM_TICKETS ) {
                return new Ticket( num1, num2, num3, num4, num5, num6 );
            } else {
                throw new NoSuchElementException("Tickets sold out");
         * Don't want people to change the tickets numbers after it has been created.
         * @return copy of tickets numbers, not the original array
        public int[] getTicketNumbers() {
            return Arrays.copyOf( numbers, numbers.length );
        public String toString() {
            return Arrays.toString( numbers );
    }Brushfire,

  • Dynamic string array

    I need to make a dynamic string array.
    Deeper explanation:
    I am trying to use a FOR loop to send a series of commands to an 8-channel device.  Each channel requires 7 (actually, 1/2 need only 5, the other 1/2 need 7) strings to set them up and the entire sequence needs to be performed 8 times.  I started a test .vi by simply using a constant array of type sting.  I can sequentially pick each string and program my device perfectly.  Now I'd like to do things like add the channel # somewhere in the mix, use variable values based on other controls in my .vi to set the parameters of the channel.
    EXAMPLE:
    The user sets certain values that determine delays and width for an 8-channel DDG (Digital Delay Generator, to some, a pulse generator).  These values then need to be loaded into the DDG.  The Strings will look something like this:
    ULSE1TATE 1
    ULSE1:WIDTH 0.009 000           *NOTEpaces behind decimal are for better viewability only
    ULSE1ELAY 0.000 000
    ULSE1YNC T0
    ULSE1:CMODE DUTY
    ULSE1COUNTER 1
    ULSE1:BCOUNTER 1
    ULSE2TATE 1
    ULSE2:WIDTH 0.000 300
    ULSE2ELAY 0.008 700
    ULSE2YNC T0
    ULSE2:CMODE NORMAL
    So widith and delay params change, the pulse# changes, and whether it's on certain channels decides if the mode is duty or normal and duty comes with the subsequent params pcount and bcount.
    help?
    PS - I am going to move the state, sync, and cmode to a common, initialize loop run only at program start, but I still need to use width, delay, and (variably) pcount and bcount.
    PPS - I am trying to edit post to diable smilies.  Commands should read:"colon, P (or D)" not ,
    PPPS - Success, at least for me.  I disabled smilies in my settings, I don't know if that means my posts won't show smilies or if just what I am looking at won't show smilies, any responders let me know how it's showing for you.
    Message Edited by Radiance_Jon on 07-16-2007 01:48 PM
    Message Edited by Radiance_Jon on 07-16-2007 01:52 PM

    smercurio_fc wrote:
    Well, in my experience I have found that dealing with errors early on is the best course of action as it leads to less headaches down the road...
    Auto-indexing is one of the more powerful features of LabVIEW. If you're familiar with text-based languages it's equivalent to the "foreach" statement. Basically it allows you to wire an array into a for-loop and the size of the array tells LabVIEW how many times the loop needs to execute. Inside the loop LabVIEW peels of each element of the array in order for each iteration of the loop. Looks like this:
    My comment regarding not needing the sequence frame was related to using the error cluster since that wire would allow you enforce data dependency like so:
    Note that the VISA resource wire does the same thing.
    "I got a little aggravated at how NI seemed to handle the loops in those two frames concurrently".  That's because LabVIEW is a data-flow language, and not a sequenced language like C or VB. In fact, that's one of the things that makes LabVIEW so powerful.
    Message Edited by smercurio_fc on 07-16-2007 04:48 PM
    MAN!  I KNEW that!!!!  GGRRRRR!!!  That makes sense.  Actually that's WHY I connected the error lines in the first place was to aide in flow control.  OH!!!  Still getting used to LabVIEW. 
    But I still have a question related to flow control.  Check out the pic below.  LabVIEW runs everything in a seemingly random order... well at least where it STARTS each chain of data.  It obviously starts with the static constants or the earliest data in each chain, but I can't figure out how in the world it's deciding WHICH chain to start first.  It kind of seems to go with the lower right and work it's way to top-left, but it doesn't exactly do that either.  I dunno if it's worth you answering this concern or not, but if you got one for me I'd be much obliged. 
    I should take a LabVIEW class!  Yeah right, as if they'd let me... R&D means I won't need it tomorrow ;( which stinks cause I'm liking LabVIEW the more I learn it.  (I was not fond of it in the beginning, but that was my stubborness). 
    thanks again so much for all your help!!!!
    Also, I am using all those strings to make my display appear as I want it to... I wonder if there is another way?  I am aware of system labels, but I like the look of the recessed, grayed control boxes better.
    Message Edited by Radiance_Jon on 07-16-2007 05:06 PM

  • Buttons in arrays - no action

    I have 36 buttons I need action on. To avoid a lot of similar
    commands, I am trying to assign the button names in an array using
    a for loop. Tracing the array values, gives the correct button
    names, but there is no action when I press the buttons. If anyone
    can tell me the reason, I would really appreciate it. Thanks in
    advance!
    Here is the code:
    var farge_btn_tbl:Array = new Array(4); // Array assigning
    button instance names (works fine)
    var farge_fr_tbl:Array = new Array(4); // Array assigning
    frame label names (works fine)
    for (var i:Number = 0; i < 4; i++) {
    farge = "farge" + String(i+1); // The button instance names
    are assigned
    farge = "fargen" + String(i+1); // The frame label names are
    assigned
    farge_btn_tbl
    = farge; // Placing the values in the button array
    farge_fr_tbl = fargen; // Placing the values in the
    frame array
    farge.onRelease = function(){ // Trying to get action on the
    buttons
    gotoAndStop(fargen + String(i+1)); // it doesn't work
    }

    Thankyou!
    That worked fine. First it didn't work on button 4, but when
    I changed both the button instance names to start with 0 ending
    with 3 (instead of starting with 1 ending with 4, and did the same
    with the instance names, than it worked perfect! I have spend all
    the day on this headache (it's 17 pm here in Norway), so I really
    appreciate your help!
    Anyway the buttons are inside a movie clip. The code I wrote
    here, was just a test file, not my big project file. Is it possible
    to put the movie clip instance name in front of this? Or after? ( I
    am a newbee.)
    Or should I put the code in the timeline of the
    movieclip?

  • How to output last 4 arrays from a For Loop?

    Hi People,
    I am almost at the end of my tether. I really hope someone could please help me.
    Any input would be welcome. VI attached.
    VI explanation:
    I initialize an array.
    The random number generator simulates my camera input.
    Depending on which iteration it is, the data is added into one of four output arrays.
    'x-y*floor(x/y)' gives a remainder value of 0, 1, 2 or 3.
    'Case Selector' just adds 1 to 'x-y*floor(x/y)' to get case 1, 2, 3 or 4.
    Shots 1, 5, 9 etc are added to Array 1 (Case 1).
    Shots 2, 6, 10 etc are added to Array 2 (Case 2).
    Shots 3, 7, 11 etc are added to Array 3 (Case 3).
    Shots 4, 8, 12 etc are added to Array 4 (Case 4).
    Averaged Output displays the averaged value i.e. the total value divided by the number of shots saved in that array ('Set (IQ+1)').
    My problems are:
    1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
    Where should I place my file save diagram disable so that it does this?
    Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)
    Putting it outside the main For Loop with auto-indexing off gives me only the last set of data. (I need the output for 4 Arrays, not just the last run)
    Putting it inside the main For Loop (as shown) gives me the same number of files as number of iterations. (Again not feasible due to large number of files that will be generated and slow camera capture)
    For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
    2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
    3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
    I am using Labview 2010.
    Thanks so much,
    Jaslyn
    Solved!
    Go to Solution.
    Attachments:
    Help Understanding Arrays and file paths (10).vi ‏26 KB

    Thanks so much Lennard!!
    Hi JKSH,
    I've been busy trying to complete the dang code, but for completeness so that other users can learn too, I shall answer your queries. Thanks for looking in.
    First, what do you mean by "add"? Your code in your case strcuture sums your input values, so your array size doesn't change. However, you also said "Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)" -- it sounds like you are expecting an array with thousands of elements. So, what should "Output Array N" look like?
    Ans: Output Array N should be a 4x4 array of the summation of all the numbers generated during every 4th iteration.
    i.e. if random number 1=1, random number 2=2, etc, And 'No of iterations' is 12,
    Output Array 1 should be 1+5+9:
    15 15 15 15
    15 15 15 15
    15 15 15 15
    15 15 15 15
    (Note: Most of your arrays are 4x4, but in Case #2 you created 128x128. I prersume this is a typo?)
    Ans: Kind of, I'm using a 4x4 array of randomly generated numbers as an example but my actual data will be the 128x128 pixel output of a camera. And during actual experimentation, 'No of Iterations' will number in the thousands.
    Second, why do you add your "simulated camera input" to the "Initialized Array"? You can add it direcly to the previous output inside your case structure.
    Ans: See answer to question 3
    Third, have a look at shift registers: http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm. Use them instead of Feedback Nodes to make your code tidier.
    Ans: I did try.. But I can't seem to add shift registers to the case structure, only the for loops outside. Are you sure it can be done..?
    jaslyn wrote:
    1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
    Where should I place my file save diagram disable so that it does this?
    For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
    You will need to call "Write to Text File.vi" 4 times to write 4 files. So, you should finish your loop, then call this VI 4 times.
    Ans: How do I get it to extract the data from each of the 4 cases in my case structure?
    jaslyn wrote:
    2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
    You can create strings first, then convert them into paths: http://zone.ni.com/reference/en-XX/help/371361G-01/glang/string_to_path/
    Thanks
    jaslyn wrote:
    3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
    I'm not sure what you're asking; can you please clarify what you mean by "avoid using Memory Manager"? But anyway, you've actually initialized FIVE arrays: 1 outside the loop, and 1 inside each case.
    I've read that to avoid fluctuations in memory usage, it is a good idea to initialize arrays to their expected size before the start of data collection. That was just what I was trying to do.

  • Acsessing an array of objects

    Here's my dilemna...
    I have a class called employess with variables such as names, hours worked etc. Then I have another class called Pay which instantiates an array of employee objects thus:
    Employee[] emp = new Employee[1000];
    I can fill the array from this class and search it etc no probs but I have another class (class Other)which also needs to access the emp array.
    My question is: How can I access the emp array(and therefore access the variables within class Employee) from this class Other???
    Any help would greatly relieve my headache and help me sleep better....

    Why not simply
    public class Pay {
    public Employee[] getEmployees(){
        return emp;
    }and
    public class Other {
         Pay pay = ... ; // can you get the pay instance here?
         Employee[] employees = pay.getEmployees();
    Not knowing your application, it is difficult to comment in depth, but maybe you should make a class to encapsulate your set of employees, and put the search methods (among others) in. That would give you leanest Pay and Other class and avoid rewriting cdode.Also, it sounds strange that a class called Pay should fill the employees set.
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Initializing Array in a Unique Manner

    Hi All,
    I'm new on this and have tried for several hours how to do the following "simple" thing without any success. I'm using a cDAQ 9171 with a NI 9263 analog output module.
    My Problem: I need to start the following program when Start button is pushed. Please, in order of priority I'm giving you what I have to do.
    1. Analog output from an array that haves fixed values. Let it be 5 ; 4 ; 3 ; 2 ; 3 ; 4 . So I need to stay 1min in each value and then repeat the whole array for  10 times more.
    I Tried with the attached project, but it only generated a 1V signal, even when the appended array was changing...I don't know what happened.
    2. I wanted to create automatically the array i mentioned before. But it gave me so much headache that i left it.
    Thanks in advance for your help.
    Solved!
    Go to Solution.
    Attachments:
    v0.3.zip ‏24 KB

    Take advantage of auto-indexing tunnels to break out the data in your array.  And if you use 1 channel 1 sample rather than N channels 1 sample, you won't need to take that scalar value and build it back into an array.
    Attachments:
    fte v0.3MOD.vi ‏37 KB

Maybe you are looking for