mercredi 1 juillet 2015

I need to Implement the following code segment in the ARC assembly language

if  x <= y:
    y = y + 1
else if x != z
    y = y-1
else
    z = z + 1

This is what i have for my Arc assembly code. Im fairly new at this so im not too sure how to make the if/else statement into assembly code.

! This program executes an If/else statement
    .begin
    .org 2048
prog1:  ld  [X], %r1    ! this loads memory X into register 1 
        ld  [Y], %r2    ! this loads memory y into register 2


X:  0
Y:  0
Z:  0
    .end

my if statement returns the wrong value every time, is it my arrays?

import java.util.Scanner;
public class Start
{

public static void main(String[] args) 
{
    Scanner reader = new Scanner(System.in);
    String name = null, helloworlduserattempt = null;
    Boolean helloworldcorrect;

    System.out.println("Welcome to the Java Teacher!");
    System.out.println();
    System.out.println("Type in your name");
    name = (reader.nextLine());
    System.out.println("First " + name + ", lets go over some basics. \nAnything you type to the console in Java Teacher will appear like this;");
    System.out.println();
    System.out.println("___________________________________________________________________________________________");
    System.out.println();
    System.out.println("*your printed text here*");
    System.out.println();
    System.out.println("___________________________________________________________________________________________");

    System.out.println("\n\nThe first exercise is called \"hello world\". This is the starting point for most people while learning how to code.\nThis simply entails writting the phrase \"hello world!\" to the console.");
    System.out.println("\nTo do this, we need to type in \"System.out.println(\"Hello World\");\"");
    System.out.println("\nLets have a look at what that actually means. System.out.println basically tells the system to output to the console the following message on a new line.\nYou could type print instead of println, but this would not write to a new line. Also, notice that System has a capital S");


    System.out.println("Now you try! type in what you think will print \"Hello World!\" to the console");

    do 
    {
    helloworlduserattempt = (reader.nextLine());

    String[] array = helloworlduserattempt.split("\""); 
    array[0] = array[0] + "\"";
    array[2] = "\"" + array[2];
    System.out.println(array[0] + array[1] + array [2]);
    if (helloworlduserattempt == "System.out.println(\"Hello World!\");")
        {
    System.out.println("___________________________________________________________________________________________");
    System.out.println("Hello World!");
    System.out.println("___________________________________________________________________________________________");
    System.out.println("Well done " + name  + "! that was perfect");
    helloworldcorrect = true;
        }
    else if (array[0] == "System.out.println(\"" && array[2] == "\");")
    {
    System.out.println("___________________________________________________________________________________________");
    System.out.println(array[1]);
    System.out.println("___________________________________________________________________________________________");
    System.out.println("youve got the code right " + name + ", but the actual text is incorrect");
    helloworldcorrect = false;
    }
    else 
        {
        System.out.println("___________________________________________________________________________________________");
        System.out.println("Error");
        System.out.println("___________________________________________________________________________________________");
        System.out.println("Oops! thats not quite right " + name + ", try again. remember you can look up at what i said earlier!");
        helloworldcorrect = false;
        }
    }
    while (helloworldcorrect = false);
}
}

every time i input the correct answer ( System.out.println("Hello World!");) it says error. ive researched possible solutions, and been through the entire code three times now, any help or guidance would be greatly appreciated.

Mail Chimp IF statment

I am trying to set up specific RSS feeds to subscribers based on region selection. I am attempting to use a Conditional Merge Tag Block. What I have below will not work and I am not sure why.

*|IF:REGION = No Region|*News Headlines Offline
No headlines for you...Your region is not set.*|ELSEIF:REGION = North America|*
North American News Headlines

*|FEEDBLOCK:http://ift.tt/1C9lXDn
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = European Union|*
European Union News Headlines

*|FEEDBLOCK:http://ift.tt/1FQVO6R
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = Africa|*
African News Headlines

*|FEEDBLOCK:http://ift.tt/1C9lXDp
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = East Asia|*
East Asian News Headlines

*|FEEDBLOCK:http://ift.tt/1FQVO6T
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = South Asia|*
South Asian News Headlines

*|FEEDBLOCK:http://ift.tt/1C9lXTD
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = Central America / Caribbean|*
Central American/Caribbean News Headlines

*|FEEDBLOCK:http://ift.tt/1FQVQvC
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = Eastern Europe / Russia|*
Eastern Europe/Russia News Headlines

*|FEEDBLOCK:http://ift.tt/1C9lXTF
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = Middle East|*
Middle East News Headlines

*|FEEDBLOCK:http://ift.tt/1C9m01K
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = Oceania|*
Oceania News Headlines

*|FEEDBLOCK:http://ift.tt/1FQVQLT
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSEIF:REGION = South America|*
South American News Headlines

*|FEEDBLOCK:http://ift.tt/1FQVQLW
*|FEEDITEM:TITLE|**|END:FEEDITEMS|**|END:FEEDBLOCK|**|ELSE|*nil*|END:IF|*
Your region is set to *|REGION|*.  Change Region >>

Get field details inside list without large if else condition in Java

I have a List of objects. The list is quiet big. All the values are String. Currently I'm doing for each loop with if condition. But readability will not be good and it becomes lengthy. Following is the code snippet:

List<Fields> fieldList = <(device,value),(quantity,value),(position,value),(Note,value),(Model,value),(LotNumber,value)...>;    
for(Fields fl : fieldList)
{
 if(fl.name.equals("device"))
  doSomething();
else if(fl.name.equals("quantity"))
 doSomething();
//This goes on
}

Please suggest a better way. Note: Time is not a factor.

Create a dynamic 'if' statement in Excel without VBA

I have a rather large excel data set that I'm trying to summarise using up to 3 dimensions: region, sector, industry. Any combination of these dimensions can be set or left blank and I need to create a formula that accommodates this WITHOUT using VBA.

Within the data I've set up named ranges to refer to these dimensions.

I'm using an array formula but I'd like to dynamically create a string which is then used as the boolean argument in the array formula.

For instance if:

A1 = "Hong Kong" (region)
B1 = <blank> (sector)
C1 = <blank> (industry)

I create a dynamic string in D1 such that

D1 = (region="Hong Kong")

I then want to use the string in D1 to create an array formula

E1 = {counta(if(D1,employees))}

However, if the user includes a sector such that:

 A1 = "Hong Kong" (region)
 B1 = "finance" (sector)
 C1 = <blank> (industry)

Then I want the string in D1 to update

D1 = (region="Hong Kong")*(sector="finance")

Which then automatically updates the value in E1 which still has the same formula.

E1 = {counta(if(D1,employees))}

Is this possible? Alternatively is there any other way of achieving the same outcome, keeping in mind that I need to be able to copy D1 and E1 down into different rows so that different combinations of the dimensions can be viewed simultaneously.

Thanks.

Best way to fire different functions for different window sizes

I have a site, that behaves in different ways for mobile and desktop devices. I could use this selector to choose wether to fire functions:

if($(window).width < 768) {
    // fire functions for mobile
} else {
    // fire functions for desktop
}

How does this snippet work, if I write a lot of stuff into the placeholders? Does it skip the whole if or else code (to reduce loading time)?

Should I create variable functions like so, to keep it clean, or should I trigger everything my if {} else {} function?

// Is this one better?
if ($(window).width() < 768) {

    // $('something').something();
    // var another = $('another');
    // another.something();
    // lets guess lots of stuff to do here
    // like 200 lines of code

} else { 

    // $('something').something();
    // var another = $('another');
    // another.something();
    // lets guess lots of stuff to do here
    // like 200 lines of code
}

// Or this one?
var mobileFunctions = function() {

    // $('something').something();
    // var another = $('another');
    // another.something();
    // lets guess lots of stuff to do here
    // like 200 lines of code
}
var desktopFunctions = function() {
    // $('something').something();
    // var another = $('another');
    // another.something();
    // lets guess lots of stuff to do here
    // like 200 lines of code
}
if ($(window).width() < 768) { 
    mobileFunctions();
} else { 
    desktopFunctions();
}

Get file's modified date with condition - Batch Windows

I have a file.sql in Windows and I would like to check if the file modified date is equal to some date with a if statement.

It will check in a batch file.

This is the idea to get de date:

for %a in (file.sql) do set FileDate=%~ta

But I need that with a condition and if the condition is true, It will execute a sqlcmd command.