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
    
  
  
    
  | public class Exercise5_18 { | |
| public static void main (String[] args) { | |
| java.util.Scanner input = new java.util.Scanner(System.in); | |
| System.out.println("Number\tSquare Root"); | |
| int number = 0; | |
| double squareRoot; | |
| for (int i = 0; i <= 20; i++) { | |
| squareRoot = Math.sqrt(number); | |
| System.out.println(number + "\t" + squareRoot); | |
| number++; | 
  
    
      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
    
  
  
    
  | public class Exercise5_12 { | |
| public static void main (String[] args) { | |
| printChars ('1', 'z', 10); | |
| } | |
| public static void printChars(char ch1, char ch2, int numberPerLine) { | |
| // TODO Auto-generated method stub. | |
| int count = 1; | |
| for (int i = ch1; i <= ch2; i++,count++) { | |
| if (count % numberPerLine == 0) | 
  
    
      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
    
  
  
    
  | public class Exercise5_25 { | |
| public static void main(String[] args) { | |
| java.util.Scanner input = new java.util.Scanner(System.in); | |
| System.out.print("Please enter the amount of milliseconds to convert: "); | |
| long milliSeconds = input.nextLong(); | |
| System.out.println(milliSeconds + " milliseconds in hours, minutes and seconds is " + ((convertMillis(milliSeconds) / 3600) | |
| + " hours "+ ((convertMillis(milliSeconds) % 3600) / 60) + " minutes " + ((convertMillis(milliSeconds) % 3600) % 60) + " seconds.")); | |
| } | |
| private static long convertMillis(long milliSeconds) { | 
  
    
      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
    
  
  
    
  | import java.util.Scanner; | |
| // Displaying the first day of each month. | |
| public class Exercise4_28 { | |
| public static void main (String[] args) { | |
| Scanner input = new Scanner(System.in); | |
| System.out.println("Please enter the year: "); | |
| int year = input.nextInt(); | |
| System.out.println("Please enter the day number: "); | 
  
    
      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
    
  
  
    
  | // Conversion of miles to kilometers. | |
| public class Exercise4_4 { | |
| public static void main(String[] args){ | |
| System.out.println("Miles Kilometers"); | |
| System.out.println("----------------------"); | |
| int miles = 1; | |
| while (miles <= 10) { | |
| System.out.println(miles + " " + miles * 1.609); | |
| miles++; | 
  
    
      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
    
  
  
    
  | // Coversion of kilograms to pounds. | |
| public class Exercise4_5 { | |
| public static void main (String[] args){ | |
| System.out.println("Kilograms Pounds Pounds Kilograms"); | |
| System.out.println("--------------------------------------------------"); | |
| int kilograms = 1; | |
| int pounds = 20; | |
| int count = 1; | |
| while (count <= 100 ) { | 
  
    
      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
    
  
  
    
  | // Prime numbers between 2 and 1000. | |
| public class Exercise4_20 { | |
| public static void main (String[] args){ | |
| int count = 0; | |
| int number = 2; | |
| while (number <= 1000) { | |
| boolean isPrime = true; | |
| for (int divisor = 2; divisor <= number / 2; divisor++) { | |
| if (number % divisor == 0) { | |
| isPrime = false; | 
  
    
      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
    
  
  
    
  | import java.util.Scanner; | |
| // Loan amortization schedule. | |
| public class Exercise4_22 { | |
| public static void main (String[] args) { | |
| Scanner input = new Scanner(System.in); | |
| System.out.println("Loan Amount: "); | |
| double loanAmount = input.nextDouble(); | |
| System.out.println("Number of years: "); | 
  
    
      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
    
  
  
    
  | import java.util.Scanner; | |
| // Comparing loans with various interest rates. | |
| public class Exercise4_21 { | |
| public static void main(String[] args) { | |
| java.util.Scanner input = new Scanner(System.in); | |
| System.out.println("Please enter the loan amount: "); | |
| int loanAmount = input.nextInt(); | |
| System.out.println("Please enter the loan term: "); | 
  
    
      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
    
  
  
    
  | import java.util.Scanner; | |
| // Summation of a series. | |
| public class Exercise4_23 { | |
| public static void main (String[] args) { | |
| Scanner input = new Scanner(System.in); | |
| double sum = 0; | |
| for (double i = 0; i <= 50000; i++) { | |
| sum += 1 / (i + 1); | |
| } | 
NewerOlder