import java.util.Arrays;
public class Assignment05{
public static void displayGreeting(){
System.out.println("Hello, and welcome!");
}
public static void displayText(String txt){
System.out.println(txt);
}
public static void printTotal(int a, int b, int c){
System.out.println(a+b+c);
}
public static int getTotal(int a, int b, int c){
return a+b+c;
}
public static double averageLength(String a, String b, String c){
return (a.length() + b.length() + c.length())/3;
}
public static double getAverage(int a, int b, int c){
return (a + b + c)/3;
}
public static int lengthOfShortest(String a, String b){
if (a.length() > b.length()){
return b.length();
}
else{
return a.length();
}
}
public static String stringOfStars(String txt){
String newTxt = "";
while (newTxt.length() < txt.length()){
newTxt += "*";
}
return newTxt;
}
public static String maxStringOfStars(String txt, String txt1){
String newTxt = "";
if (txt.length() >= txt1.length()){
while (newTxt.length() < txt.length()){
newTxt += "*";
}
return newTxt;
}
else{
while (newTxt.length() < txt1.length()){
newTxt += "*";
}
return newTxt;
}
}
public static String midStringOfStars(String a, String b, String c){
String arr[] = {a, b, c};
Arrays.sort(arr);
String txt = "";
while (txt.length() < arr[1].length()){
txt += "*";
}
return txt;
}
public static void main(String[] args){
displayGreeting();
displayText("hello");
printTotal(1,2,3);
System.out.println(getTotal(2,2,43));
System.out.println(getAverage(100,13,7));
System.out.println(averageLength("a", "abc", "ab"));
System.out.println(lengthOfShortest("abc", "ab"));
System.out.println(stringOfStars("abcd"));
System.out.println(maxStringOfStars("a", "bbbbb"));
System.out.println(midStringOfStars("aaa","aa", "abcedas"));
}
}
I hope this helps!