User Tools

Site Tools


ppsolutions

This is an old revision of the document!


Solutions for assignments in Parallele Programmierung.

Assignment 1

/**
 * 
 * @author Moritz Hoffmann
 * 
 */
public class Assignment1 {
 
    /**
     * Main method
     * 
     * @param args
     *            List of numbers.
     */
    public static void main(String[] args) {
        int max = (1 << 16) - 1;
        int min = (-1 ^ (1 << 16)) + 1;
        for (String str : args) {
            try {
                int i = Integer.parseInt(str);
                if (i >= min && i <= max) {
                    System.out.println(i + 1);
                } else {
                    System.out.println("Number " + i + " out of range.");
                }
            } catch (NumberFormatException e) {
                System.out.println("Failed to convert to number: " + str);
            }
        }
    }
}
ppsolutions.1235641779.txt.gz · Last modified: 2009/02/26 10:49 by moritz

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki