Monday, April 28, 2008

Linuxgym-Chap4

http://www.ibm.com/developerworks/aix/

Q2 : Character count piping
Experiment by using the command "cat | wc -m", typing a few lines, and then using ctrl-D to return to the command prompt. This outputs a single number indicating the number of characters you've typed. Unlike the previous question, no filename is printed.
Modifying this technique, store the number of characters of the file /usr/local/linuxgym-data/gutenberg/0ws0310.txt into a file called "pipecount.txt" with no other text, such as the filename.

A:
wc -m /usr/local/linuxgym-data/gutenberg/0ws0310.txt ---> count characters
echo [number of charater] > pipecount.txt
Q4:View the end of a file
Store the last 103 lines of the file "/usr/local/linuxgym-data/gutenberg/4mwsm10.txt" into the file "lastlines.txt". Note that this should include both non-empty and empty lines
A :

tail -n103 /usr/local/linuxgym-data/gutenberg/4mwsm10.txt > lastlines.txt

Q5:Append the output
Copy the file /usr/local/linuxgym-data/census/a-j_malenames.txt to a file called appendix.txt in your ch4-pipewild directory. Append to appendix.txt the contents of /usr/local/linuxgym-data/census/k-z_malenames.txt making no other modifications.

A:
cp usr/local/linuxgym-data/census/a-j_malenames.txt appendix.txt
cat /usr/local/linuxgym-data/census/k-z_malenames.txt >> appendix.txt

Q6:

Sunday, April 27, 2008

PF First Assigment

Part I
- UnifiedDomination
4.75 / 5 marks

UnifiedDomination has repeated code for reading the two players' names

Part II
- Task 1: total # of armies calculation
2.5 / 2.5 marks

- Task 2: accessor functions
2.5 / 2.5 marks

- Task 3: constructors
5 / 5 marks

- Task 4: Player.startTurn
2.5 / 2.5 marks

- Task 5: Player.placeArmy
3.25 / 3.75 marks

placeArmy() breaks encapsulation of the Territory class

- Task 6: Player.attack
3.75 / 3.75 marks



YOUR MARK

24.25/25

The world is flat

Time is truly money: shaving even five seconds off the processing time of an order is significant(P41)
The gains in productivity will be staggering for those countries, companies and individuals who can absorb the new technological tools.(P47)

Sunday, April 6, 2008

Reflec week 6

Mid-Exam
"Time flies" that 's true .
Oh man .You 're such a lazy guys
C'mon .Finish the programming soon and take a break.

Friday, April 4, 2008

Lab 6 PF

import java.util.*;

public class Concert
{ private final double TAX_RATE = 0.21;
private final int PARTNERS = 3;
private Guards guards = new Guards();
private Stadium stadium = new Stadium();
private double BAND = 10000.00;
private Shirts shirts;
public Concert()
{ stadium.sell();
shirts = new Shirts();
showOutput(); }

void showOutput()
{ System.out.println("Total attendance was " + stadium.attendance());
System.out.println("My take is $" + twoDecimals(myTake()));
System.out.println(); }

private double myTake()
{ return nett() / PARTNERS; }

private double tax(double amount)
{ return amount * TAX_RATE; }

private double nett()
{ double profit = profit() + shirts.profit();
return profit - tax(profit); }

private double profit()
{ return income() - cost(); }

private double income()
{ return stadium.income(); }

private double cost()
{ double cost = BAND + stadium.cost() + guards.cost(stadium.attendance()) ;
return cost; }

private double twoDecimals(double amount)
{ int intResult = (int) (amount * 100);
return intResult / 100.0; }
}
-----------------------------------------------------------------------------


public class Stadium
{ private final double RENT = 20000.00;
private final double SECURITY_RATE = 0.32;
private Guards guards;
private SeatGroup cheap, great;

public Stadium()
{ cheap = new SeatGroup("cheap", 2000, 60.00);
great = new SeatGroup("great", 100, 500.00); }

public void sell()
{ cheap.sell();
great.sell(); }

public int attendance()
{ return cheap.sold() + great.sold(); }

public double income()
{ return cheap.income() + great.income(); }

public double cost()
{ return RENT; }
}
--------------------------------------------
import java.util.*;
import java.util.Random;
public class SeatGroup
{ private Scanner input = new Scanner(System.in);
private Random random = new Random(121);
private String name;
private int number;
private double price;
private int sold;

public SeatGroup(String name, int number, double price)
{
this.name = name;
this.number = number;
this.price = price;
}

public int sold()
{
return sold;
}
public void sell()
{
sold = generateSold(); //You would also need to change the prompt below to something meaningful.

}


private int generateSold()
{
double value = random.nextDouble();
return (int) (value * number);
}



public double income()
{
return price * sold;
}
}

-------------------------------------------------------

public class Guards
{
private final int PER_GUARD = 200;
private final double RATE = 56.00;
private final int HOURS = 6;


public double cost(int attendance)
{
// Refer tutorial notes and lecture notes to calculate cost
return RATE * HOURS * guards(attendance);

}

private int guards(int attendance)
{
return roundUp(attendance / PER_GUARD);
}

private int roundUp(double value)
{
return (int) Math.ceil(value);
}
}
--------------------------------------------

import java.util.*;

public class Shirts

{
private final double costs =2;
private final double print =1;
private final double price =40;
private final double number =600;
private int sold;

private Scanner input = new Scanner(System.in);



public Shirts()
{
System.out.print("Number of shirts sold :" );
sold = input.nextInt();
}

public double profit()
{
return price * sold - costs();
}

private double costs()
{
return costs * print * number ;
}


}

Wednesday, April 2, 2008

Evaluating Information Found on the Internet




The World Wide Web offers information and data from all over the world. Because so much information is available, and because that information can appear to be fairly “anonymous”, it is necessary to develop skills to evaluate what you find. When you use a research or academic library, the books, journals and other resources have already been evaluated by scholars, publishers and librarians. Every resource you find has been evaluated in one way or another before you ever see it. When you are using the World Wide Web, none of this applies. There are no filters. Because anyone can write a Web page, documents of the widest range of quality, written by authors of the widest range of authority, are available on an even playing field. Excellent resources reside along side the most dubious. The Internet epitomizes the concept of Caveat lector: Let the reader beware. This document discusses the criteria by which scholars in most fields evaluate print information, and shows how the same criteria can be used to assess information found on the Internet.


What to consider:
Authorship
Publishing body
Point of view or bias
Referral to other sources
Verifiability
Currency

How to distinguish propaganda, misinformation and disinformation
The mechanics of determining authorship, publishing body, and currency on the Internet

Authorship is perhaps the major criterion used in evaluating information. Who wrote this? When we look for information with some type of critical value, we want to know the basis of the authority with which the author speaks. Here are some possible filters:

  • In your own field of study, the author is a well-known and well-regarded name you recognize.
  • When you find an author you do not recognize:
    • the author is mentioned in a positive fashion by another author or another person you trust as an authority;
    • you found or linked to the author’s Web/Internet document from another document you trust;
    • the Web/Internet document you are reading gives biographical information, including the author's position, institutional affiliation and address;
    • biographical information is available by linking to another document; this enables you to judge whether the author’s credentials allow him/her to speak with authority on a given topic;
    • if none of the above, there is an address and telephone number as well as an e-mail address for the author in order to request further information on his or her work and professional background. An e- mail address alone gives you no more information than you already have.

Return to list of considerations

The publishing body also helps evaluate any kind of document you may be reading. In the print universe, this generally means that the author's manuscript has undergone screening in order to verify that it meets the standards or aims of the organization that serves as publisher. This may include peer review. On the Internet, ask the following questions to assess the role and authority of the "publisher", which in this case means the server (computer) where the document lives:

  • Is the name of any organization given on the document you are reading? Are there headers, footers, or a distinctive watermark that show the document to be part of an official academic or scholarly Web site? Can you contact the site Webmaster from this document?
  • If not, can you link to a page where such information is listed? Can you tell that it’s on the same server and in the same directory (by looking at the URL)?
  • Is this organization recognized in the field in which you are studying?
  • Is this organization suitable to address the topic at hand?
  • Can you ascertain the relationship of the author and the publisher/server? Was the document that you are viewing prepared as part of the author’s professional duties (and, by extension, within his/her area of expertise)? Or is the relationship of a casual or for-fee nature, telling you nothing about the author’s credentials within an institution?
  • Can you verify the identity of the server where the document resides? Internet programs such dnslookup and whois will be of help.
  • Does this Web page actually reside in an individual’s personal Internet account, rather than being part of an official Web site? This type of information resource should be approached with the greatest caution. Hints on identifying personal pages are available in
    Understanding and Decoding URLs.

Return to list of considerations

Point of view or bias reminds us that information is rarely neutral. Because data is used in selective ways to form information, it generally represents a point of view. Every writer wants to prove his point, and will use the data and information that assists him in doing so. When evaluating information found on the Internet, it is important to examine who is providing the "information" you are viewing, and what might be their point of view or bias. The popularity of the Internet makes it the perfect venue for commercial and sociopolitical publishing. These areas in particular are open to highly "interpretative" uses of data.

Read Information and its Counterfeits: Propaganda, Misinformation and Disinformation for learn more about "interpretational views" that exceed the facts.

Steps for evaluating point of view are based on authorship or affiliation:

  • First, note the URL of the document. Does this document reside on the Web server of an organization that has a clear stake in the issue at hand?
    • If you are looking at a corporate Web site, assume that the information on the corporation will present it in the most positive light.
    • If you are looking at products produced and sold by that corporation, remember: you are looking at an advertisement.
    • If you are reading about a political figure at the Web site of another political party, you are reading the opposition.
  • Does this document reside on the Web server of an organization that has a political or philosophical agenda?
    • If you are looking for scientific information on human genetics, would you trust a political organization to provide it?
    • Never assume that extremist points of view are always easy to detect. Some sites promoting these views may look educational. To learn more, read "Rising Tide: Sites Born of Hate", New York Times, March 18, 1999. (This link will take you to the online edition of the Times; you must register, free of charge, to view the article).

Many areas of research and inquiry deal with controversial questions, and often the more controversial an issue is, the more interesting it is. When looking for information, it is always critical to remember that everyone has an opinion. Because the structure of the Internet allows for easy self publication, the variety of points of view and bias will be the widest possible.

Return to list of considerations

Referral to and/or knowledge of the literature refers to the context in which the author situates his or her work. This reveals what the author knows about his or her discipline and its practices. This allows you to evaluate the author's scholarship or knowledge of trends in the area under discussion. The following criteria serve as a filter for all formats of information:

  • The document includes a bibliography.
  • The author alludes to or displays knowledge of related sources, with proper attribution.
  • The author displays knowledge of theories, schools of thought, or techniques usually considered appropriate in the treatment of his or her subject.
  • If the author is using a new theory or technique as a basis for research, he or she discusses the value and/or limitations of this new approach.
  • If the author's treatment of the subject is controversial, he or she knows and acknowledges this.

Return to list of considerations

Accuracy or verifiability of details is an important part of the evaluation process, especially when you are reading the work of an unfamiliar author presented by an unfamiliar organization, or presented in a non-traditional way. Criteria for evaluating accuracy include:

  • For a research document, the data that was gathered and an explanation of the research method(s) used to gather and interpret it are included.
  • The methodology outlined in the document is appropriate to the topic and allows the study to be duplicated for purposes of verification.
  • The document relies on other sources that are listed in a bibliography or includes links to the documents themselves.
  • The document names individuals and/or sources that provided non- published data used in the preparation of the study.
  • The background information that was used can be verified for accuracy.

Return to list of considerations

Currency refers to the timeliness of information. In printed documents, the date of publication is the first indicator of currency. For some types of information, currency is not an issue: authorship or place in the historical record is more important (e.g., T. S. Eliot's essays on tradition in literature). For many other types of data, however, currency is extremely important, as is the regularity with which the data is updated. Apply the following criteria to ascertain currency:

  • The document includes the date(s) at which the information was gathered (e.g., US Census data).
  • The document refers to clearly dated information (e.g., "Based on 1990 US Census data.").
  • Where there is a need to add data or update it on a constant basis, the document includes information on the regularity of updates.
  • The document includes a publication date or a "last updated" date.
  • The document includes a date of copyright.
  • If no date is given in an electronic document, you can view the directory in which it resides and read the date of latest modification.

If you found information using one of the search engines available on the Internet, such as AltaVista or InfoSeek, a directory of the Internet such as Yahoo, or any of the services that rate World Wide Web pages, you need to know:

  • How the search engine decides the order in which it returns information requested. Some Internet search engines "sell" top space to advertisers who pay them to do so. Read Pay for Placement? from Searchenginewatch.com.
  • That Internet search engines aren't like the databases found in libraries. Library databases include subject headings, abstracts, and other evaluative information created by information professionals to make searching more accurate. In addition, library databases index more permanent and reliable information.
  • How that search engine looks for information, and how often their information is updated. An excellent source for search engine information is Search Engine Showdown, written by Greg R. Notess.

All information, whether in print or by byte, needs to be evaluated by readers for authority, appropriateness, and other personal criteria for value. If you find information that is "too good to be true", it probably is. Never use information that you cannot verify. Establishing and learning criteria to filter information you find on the Internet is a good beginning for becoming a critical consumer of information in all forms. "Cast a cold eye" (as Yeats wrote) on everything you read. Question it. Look for other sources that can authenticate or corroborate what you find. Learn to be skeptical and then learn to trust your instincts.