4 quick java programs - beginner friendly please

User Generated

rivrenje

Programming

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 )



Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

Explanation & Answer

svkvg (96)
Carnegie Mellon University

Anonymous
Just what I needed…Fantastic!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4