4 quick java programs - beginner friendly please

User Generated

rivrenje

Programming

Description

(Use the Date Class) Write a program that creates a Date object, sets its elapsed time to 10000, 100000, 10000000, 100000000, 1000000000, 10000000000 and 100000000000 and displays the date and time using the toString() method.

Submit both source code and compiled code ( .java and .class files )




If you need files for this one, tell me please.

(Use the GregorianCalendar class) Java API has the GregorianCalendar class in thejava.util package, which you can use to obtain the year, month and day of a date. The no-arg constructor constructs an instance for the current date, and the methodsget(GregorianCalendar.YEAR), get(GregorianCalendar.MONTH), and get(GregorianCalendar.DAY_OF_MONTH) return the year, month, and day. Write a program to perform two tasks:

  • Display the current year month and day
  • The GregorianCalendar class has the setTimeInMillis(long) which can be used to set a specified elapsed time since January 1, 1970. Set the value to 1234567898765L and display the year, month, and day.

Submit both source code and compiled code ( .java and .class files )




Write a method that counts the number of letters in a string using the following header:

public static int countLetters( String s )

Write a test program that prompts the user to enter a string and displays the number of letters in the string.

Submit both source code and compiled code ( .java and .class files )





Write a method that finds the number of occurances of a specified character in a string using the following header:

public static int count(String str, char a)

For example, count("Welcome",e) returns 2. Write a test program that prompts the user to enter a string followed by a character and displays the number of occurances of the character in the string.

Submit both source code and compiled code ( .java and .class files )


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Excellent! Definitely coming back for more study materials.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags