Programming Homework Help

Java Programming Questions

Get Your Custom Essay Written From Scratch
We have worked on a similar problem. If you need help click order now button and submit your assignment instructions.
Just from $13/Page
Order Now

1.Consider the below java code:

import java.util.Scanner;

import java.io.File;

public class ScannerFromFile {

  public static void main(String[] args) {

     Scanner in = new Scanner(new File(“test.in”));

     // do something …

  }

}

              Write an exception to handle if the file “test.in” does not exist

2.Consider the below java code

public class Sample {

  public static void main(String[] args) {

     int num = Integer.parseInt(args[0]);

        ………………………………………………………..

     // The execution terminates if the value of num

     // is greater than 100

      System.out.println(“The assertion passed…”);

  }

}

Write an assertion that would terminate the program if the entered number is greater than 100

3.The Chinese animal zodiac is a repeating cycle of 12 years, with each year being represented by an animal and its related attributes. Traditionally these zodiac animals were used to date the years. In order, the 12 animals are: Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, Rooster, Dog, Pig. Each year is associated with a zodiac animal. 2019 is the year of the Pig, 2020 is the year of Rat, 2021 will be the year of Ox

Use direct access method to implement the method YearToAnimalZodiac()

4.refactor the below pieces of code:

public double areaOfCircle (double radius)  { 

   return Math.pow(radius * 3.14159, 2); 

} There is 2  more that i will attch on word file