4 quick java programs - beginner friendly please

Nov 28th, 2013
Price: $10 USD

Question description

Write a method that computes the sum of the digits of an integer. Use the following method header:

public static int sumDigits( long n )

For example sumDigits( 234 ) returns 9  ( 2+3+4)
Hint: use the % operator

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

Write a method with the following header to display three numbers in increasing order

public static void displaySortedNumbers( double num1, double num2, double num3 )

Write a test program that prompts the user to enter three numbers and invokes the method to display them in increasing order.

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

Create a class called MyTriangle that contains the following two methods:

/* Return true if the sum of any two sides is greater than the third side */
public static boolean isValid( double side1, double side2, double side3 )

/* Return the area of the triangle */
public static double area( double side1, double side2, double side3 )

Write a test program that reads three sides for a triangle and computes the area if the input is valid. Otherwise it displays the input is invalid. See Programming Exercise 2.15 for computing the area of a triangle.

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

Write a method that converts milliseconds to hours, minutes and seconds using the following header:

public static String convertMillis( long millis )

The method returns a string as hours:minutes:seconds
For example, convertMillis( 5500 ) returns a string 0:0:5 and convertMillis( 5555500000 ) returns a string 154:19:10

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

Tutor Answer

(Top Tutor) Daniel C.
School: Rice University

Studypool has helped 1,244,100 students

Review from our student for this Answer

Nov 30th, 2013
"Goes above and beyond expectations !"
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1822 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors