Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Create a new java project file, CMSC246. In it, createa new Java class, JavaA

ID: 3618463 • Letter: 3

Question

3. Create a new java project file, CMSC246. In it, createa new Java class, JavaAssignment1.  Writea

main method and static method called greatestOfThree thatreturns the greatest of three integer

values. This method will have three integer parameters. Write thecode to prompt the user to input

three integers; call this method; and code to print out the threenumbers that were sent as arguments

and the returned value in the main method.

4. In the JavaAssignment1 that was created in number3, add another static method called isSubstring

that accepts two String objects as parameters and returns true ifeither one of the strings is contained in

another. As in part three, write the code to prompt the userto input two Strings; call this method; and

code to print out the strings that were sent as arguments andresult - all in the main method.

5. Write another method that returns a double value thatrepresents the sum of the elements in an array

passed as a parameter to the method. Once again, write thecode to prompt the user to input the size

of the array and the values; call this method; and code to printout a list of the elements of the array

passed to the method and the returned sum all in the mainmethod.

6. Add a comment block to the top of the source code file toprovide some basic documentation for your

application. For example,

//---------------------------------------------------------------------------

// Class: JavaAssignment1

// Debra Duke

// CMSC 246, Spring 2010

// Java Project 1

//

// This application demonstrates several staticmethods that are called from

// the main method.

//---------------------------------------------------------------------------

Add a helper method called printHeading() to yourapplication. The heading of the method should

be

private static void printHeading()

In the code block of the method, write Java statements that outputto the console the following:

your name the course name, number and section the Javaprogram name

the project number

Include a Java statement at the beginning of your main method thatcalls the helper method,

printHeading(). This helper method is to be included in everyprogramming project that you

complete for the rest of the semester.

Explanation / Answer

please rate-thanks //--------------------------------------------------------------------------- //    Class: JavaAssignment1 //    Debra Duke //    CMSC 246, Spring 2010 //    Java Project 1 // //    This application demonstrates several staticmethods that are called from // the main method. //--------------------------------------------------------------------------- import java.util.*; import java.text.*; public class untitled {public static void main(String args[])    {Scanner in=new Scanner(System.in);     int n1,n2,n3;    String s1,s2;    printHeading();     System.out.print("Enter first number ");     n1=in.nextInt();     System.out.print("Enter second number ");     n2=in.nextInt();    System.out.print("Enter third number ");     n3=in.nextInt();     System.out.println("The largest number of "+n1+""+n2+" "+n3+" "+"is "+greatestOfThree(n1,n2,n3)+" ");    System.out.print("Enter first string ");     s1=in.next();     System.out.print("Enter second string ");     s2=in.next();    if(isSubstring(s1,s2))          System.out.print(s1+" and "+s2+" have a same substring");    else          System.out.print(s1+"and "+s2+" do not have a same substring");     } public static int greatestOfThree (int n1,int n2,int n3) {int big; big=n1; if(n2>big)    big=n2; if(n3>big)    big=n3; return big; } private static void printHeading() {System.out.println("Class: JavaAssignment1"); System.out.println("Debra Duke"); System.out.println("CMSC 246, Spring 2010"); System.out.println("Java Project 1"); System.out.println(); } public static boolean isSubstring(String s1,String s2) {int i1,i2; i1=s1.indexOf(s2); i2=s2.indexOf(s1); if(i1!=-1||i2!=-1)       return true; else      return false;       }    }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote