MIT OpenCourseWare


» ¶i¶¥·j´M
 ½Òµ{­º­¶
 ±Ð¾Ç¤jºõ
 ±Ð¾Ç®Éµ{
 ¬ÛÃö¾\Ū¸ê®Æ
 ½Ò°óÁ¿½Z
 ½Æ²ß/¹ê²ß½Òµ{
 §@·~
 ´úÅç
 ¬ÛÃö¸ê·½
 ¤½§i

½Æ²ß/¹ê²ß½Òµ{


¥»­¶Â½Ä¶¶i«×

¿O¸¹»¡©ú

¼f©w¡GµL
½Ķ¡G§õ«Û©ú(²¤¶¨Ã±H«H)
½s¿è¡G¦¶¾ÇùÚ(²¤¶¨Ã±H«H)



µû¤À¼Ð·Ç

10 ¥÷§@·~¦ûÁ`¦¨ÁZªº 60%.
2 ¦¸¤p¦Ò¦ûÁ`¦¨ÁZªº 16%.
´Á¥½¦Ò¾ÔÁ`¦¨ÁZªº 17%.
¨C¶g¾ÉÄý©M¥D°Ê¾Ç²ß¦ûÁ`¦¨ÁZªº 7% (¥²¶·°Ñ¥[¡A¨C¸`½Ò 1/3 ¤À)

§A¦³ 1-2 ¶gªº®É¶¡¥h§¹¦¨¨C¤@¥÷ªº§@·~ (½Ð°Ñ¾\²Ä¤@°ó½Òµoªº¤jºõ)¡C§@·~¿ð¥æ¤@­Ó¤u§@¤Ñ¦© 20%. ¸Ñµª·|¦b§@·~ºI¤î¦¬¥ó«á¹j¤Ñªº 2:00 pm ¤§«á©ñ¦b¸mª«Âd¸Ì­±¡A¦Ó¥B¤§«á´N¤£¦¬¸É¥æªº§@·~¡C



µù¸Ñ§Aªºµ{¦¡½X

µù¸Ñ¥i¥H³Q©ñ¦b§Aªºµ{¦¡½X¸Ì­±¡A¥Î /* ©M */ ¥]°_¨Ó¡A©ÎªÌ©ñ¦b // ¤§«áªº¦P¤@¦æ¸Ì­±. ¨Ò¦p:

/* §Aªºµù¸Ñ - ³o¬O§@·~¤@ */

// ³o¤@¦æ¦b '//' «á­±ªº¤]¬Oµù¸Ñ.

¨C­Ó¤èªkªº«e­±À³¸Ó­n¦³µù¸Ñ¨Ó´y­z³o­Ó¤èªkªº¥Î³~©M°Ñ¼Æ¡C¦b§@·~ 1 ¤§¤¤¡A¦]¬°ÁÙ¨S±Ð¨ì¤èªk¡Aµù¸Ñ¨C¤@¸sªº±Ô­z¥y¡C

ªþµù:¦pªG§Aªºµ{¦¡¨S¦³µù¸Ñ±N·|³Q¦©¤À¡C

¦pªG§Aªºµ{¦¡¤£¯à°õ¦æ©ÎªÌ¤£¯à§¹¦¨«ü©wªº¿é¥X¡A§AÀ³¸Ó¦b§Aªºµ{¦¡ªº³Ì«e­±¼Ð©ú³o¤@ÂI¡C



µ{¦¡½Xªº¥iŪ©Ê

¦b¼gµ{¦¡ªº®É­Ô¡A§AÀ³¸Óª`·Nºû«ù§Aªºµ{¦¡½Xªº¥iŪ©Ê (¨Ò¦p: ¦b§A©ÎªÌ¨ä¥L¸ÕµÛ¾\Ū¥¦ªº¤H­«·sŪ¥¦¤@¦¸ªº®É­Ô¡A¥¦¥²¶·¬Ý°_¨Ó¦X²z). ¹F¦¨³oÂIªº¤@­Ó­«­nªº¨BÆJ¤D¬OÁY±Æ¡C

§@·~À³¸Ó³QÁY±Æ¡A¤£¦Pªº°Ï¶ô´y­zÀ³¸Ó¦b¤£¦Pªº¦æ¼Æ¶}©l¡C³oÀ°§U¤Fµ{¦¡½XªºÅªµÛ§PÂ_¤£¦Pªº±±¨îµ²ºc¡AÅÞ¿è°Ï¶ôµ¥µ¥. ¥t¥~¨C¤@¦æ¥u¼g¤@­Ó±Ô­z¥y¡C½Ð°Ñ¦Ò¤U¦C½d¨Ò¡G

public class Example {public static void main(String args[])
{int i;int b=5;double a=5.22;double d;d=(a-b)*100;
System.out.println("d="+d);i=(int)d;System.out.println("i = "+i);}}

³o¬Ý°_¨Ó«Üºë²¡A¦ý¬O¤£¯àÀ°§U¨ä¥L¤H¾\Ū³o¥÷§@·~¡C§A¥i¥H¥Î Forte ¨Ó»´©öªºÁY±Æ¡C§A¥u­n¤@¦æ¼g¤@­Ó±Ô­z¥y¡AµM«áÁY±Æ´N¦Û°Ê¥Ñ Forte §¹¦¨¡C§A¤]¥i¥H¦bµ{¦¡½X½s¿è¾¹¸Ì­±ÂI¿ï¥kÁäµM«á¿ï¾Ü¡u­«±Æµ{¦¡½X('Reformat Code')¡v¨Ó§ó¥¿ÁY±Æªº°ÝÃD¡C¦pªG§A¤@¦æ¼g¤@­Ó±Ô­z¥y¡A§Aªºµ{¦¡·|³QÁY±Æ¦Ó¬Ý°_¨Ó¹³¬O³o¼Ë¡C

public class Example
{
public static void main(String args[])
{

}
}

³o­Ó¨Ò¤l¤]Åã¥Ü¤F¿ï¾Ü©úÅ㪺ÅܼƦWºÙªº­«­n©Ê¡C·í¾\Ūµ{¦¡½Xªº®É­Ô¡AÅܼƪº¦WºÙ³q±`¬OÁA¸Ñ¶}µoªÌ¥Î·NªºÃöÁä (³o¦b¤£¯à°õ¦æªºµ{¦¡½X·í¤¤§ó¬O¦³Ãö) ¨Ï¥Î©úÅ㪺ÅܼƦWºÙÅý°£¿ù°_¨Ó§ó®e©ö¡C¥Î i ¦Ó¤£¥Î sheepcounter ´X¥G¤£·|¬Ù¤U¥ô¦ó®É¶¡¡C¨Ï¥Î¥ô·NÅܼƦWºÙ³y¦¨ªº²V²c±`±`·|³y¦¨¤@¨Ç®É¶¡ªº·l¥¢¡A¦³®É­ÔÁÙ¦]¦Ó·l¥¢¤j¶q®É¶¡¡C

Java®¬Oª@¶§¹q¸£¦b¬ü°ê»P¨ä¥L°ê®aªº°Ó¼Ð©Îµù¥U°Ó¼Ð¡C




Grading Policy

10 problem sets worth 60% of the total grade.
2 quizzes worth 16% of the total grade.
Final exam worth 17% of the total grade.
Weekly tutorial and active learning session worth 7% of the total grade.(Mandatory attendance, 1/3 point per session)

You will have 1-2 weeks to complete each problem set (see outline handed out on first day of class). Problem sets that are 1 working day late will be subject to a 20% penalty. Solutions will be placed in the locker after 2:00 pm one working day after a problem set is due, and no problem sets will be accepted after that time.



Commenting Your Code

Comments may be incorporated in your code by enclosing them between /* and */ comment delimiters, or following // on a single line. For example:

/* your comment here - this is problem set one */

// The rest of a line which follows a '//' is also a comment.

A comment should appear at the start of each method describing the purpose of the method and the method's arguments. In Problem Set 1, since we haven't covered methods yet, comment each group of statements.

Note: Points will be taken off if your code is not commented.

If your program does not run or does not produce the desired output, you should state this as a comment at the start of your code.



Readability of Code

While programming, you should take care to see that your code or program is readable (i.e. it will make sense to you when you read it again and it will make sense to other people who try to read it). One important step in achieving this is indenting.

The program should be indented so that different blocks start in different columns. This helps the reader of the code in identifying the various control structures, the logical blocks etc. Also write only one statement per line. For example, take the sample code given below.

public class Example {public static void main(String args[])
{int i;int b=5;double a=5.22;double d;d=(a-b)*100;
System.out.println("d="+d);i=(int)d;System.out.println("i = "+i);}}

This may seem compact but this does not help a new person to read the program. It is very easy to indent using Forte. All you have to do is type one statement per line and indenting is done automatically in Forte. You can also right-click in the Source Editor and choose 'Reformat Code' to correct any alignment problems. This is how the code will appear if there is only one statement per line and if the code is indented.

public class Example
{
public static void main(String args[])
{

}
}

This example also shows the importance of choosing sensible variable names. When reading code the variables often provide the key to what the intentions of the programmer might have been (this is particularly relevant in the case of programs which do not work.) Using sensible names for variables makes debugging possible. There is rarely time saved by using i instead of sheepcounter. Often it is time lost, and in some cases a great deal, due to the confusion that an arbitrary choice of variable names may cause.

Java® is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.




 
MIT Home
Massachusetts Institute of Technology Terms of Use Privacy