Last active
September 4, 2015 20:36
-
-
Save AnnaBoro/44da8813cd2577102194 to your computer and use it in GitHub Desktop.
lesson1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame10 { | |
public static void main(String[] args) { | |
int secIn3Week = 60 * 60 * 24 * 7 * 3; | |
System.out.println(secIn3Week); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame13 { | |
public static void main(String[] args) { | |
System.out.println(299792458.0 * 100 / 1000000000); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame14 { | |
public static void main(String[] args) { | |
double c = 299792458; | |
double ops = 2200000000d; | |
System.out.println(c * 100 / ops); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame29 { | |
public static void main(String[] args) { | |
String str1 = "It's a wonderful world! "; | |
String str2 = "Yes!"; | |
String str3 = " "; | |
int i = 111; | |
System.out.println(str1); | |
System.out.println(str1 + str2); | |
System.out.println(str1 + i); | |
System.out.print(str1); | |
System.out.println(str3); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame30 { | |
public static void main(String[] args) { | |
String name = "Anna"; | |
System.out.println(name.length()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame32 { | |
public static void main(String[] args) { | |
String mjQuote = "I've failed over and over and over again in my life and that is why I succeed!"; | |
System.out.println(mjQuote.charAt(mjQuote.length()-1)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame34 { | |
public static void main(String[] args) { | |
String mjQuote = "I've failed over and over and over again in my life and that is why I succeed!"; | |
System.out.println(mjQuote.substring(mjQuote.indexOf("succeed"), mjQuote.indexOf("succeed") + "succeed".length())); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame35 { | |
public static void main(String[] args) { | |
String mjQuote = "I've failed over and over and over again in my life and that is why I succeed!"; | |
System.out.println(mjQuote.substring(mjQuote.indexOf("again"), mjQuote.indexOf("again") + "again".length())); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Frame38 { | |
public static void main(String[] args) { | |
String mtQuote = "Let us always meet each other with smile, for the smile is the beginning of love."; | |
System.out.println(mtQuote.replaceAll("smile", ":)")); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Homework3 { | |
public static void main(String[] args) { | |
long milliInSec, days, hours, min, sec; | |
milliInSec = System.currentTimeMillis() / 1000; | |
days = milliInSec / (24 * 60 * 60); | |
hours = (milliInSec % (24 * 60 * 60)) / (60 * 60); | |
min = (milliInSec % (60 * 60)) / 60; | |
sec = milliInSec % 60; | |
System.out.println(days + " : " + hours + " : " + min + " : " + sec); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Homework5 { | |
public static void main(String[] args) { | |
double value = 36.6; | |
String valueToString = String.valueOf(value); | |
int dotIndex = valueToString.indexOf("."); | |
System.out.println(valueToString.substring(0, dotIndex)); | |
System.out.println(valueToString.substring(dotIndex + 1)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson1; | |
public class Homework6 { | |
public static void main(String[] args) { | |
String s = "Education is the most powerful weapon which you can use to change the world."; | |
String t = "An investment in knowledge pays the best interest."; | |
System.out.print(s.substring(s.indexOf("use"), s.indexOf("use") + ("use").length()) + " "); | |
System.out.print(t.substring(t.indexOf("knowledge"), t.indexOf("knowledge") + ("knowledge".length())) + " "); | |
System.out.println(s.substring(s.indexOf("to change the world"), s.indexOf("to change the world") + | |
+ ("to change the world").length())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment