25. september 2009 - 09:46Der er
11 kommentarer og 1 løsning
String Sorter
Hi Experts, I am new to java programming, and i've an assignment from college, please help me with this question:
Write a program that reads in three strings and prints the lexicographically smallest and largest one: Please enter three strings: Tom Dick Harry The inputs in sorted order are: Dick Harry Tom Use the following class as your main class: import java. util.Scanner; /** This is program sorts three strings. */ public class StringSorter { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Please enter three strings:"); String str1 = in.nextLine(); String str2 = in.nextLine(); String str3 = in.nextLine(); StringSet s = new StringSet(str1, str2, str3); System.out.println("The inputs in sorted order are:\n" + s.getSmallest() + "\n" + s.getMiddle() + "\n" + s.getLargest()); } } Complete the following class in your solution: /** This class finds the smallest, middle, and largest of three strings. */ public class StringSet { /** Constructs a string set that processes three strings. @param str1 the first string to sort @param str2 the second string to sort @param str3 the third string to sort */ public StringSet(String str1, String str2, String str3) { . . . } /** Gets the smallest string in the string set. @return smallest the smallest of three strings */ public String getSmallest() { . . . } /** Gets the largest string in the string set. @return largest the largest of three strings */ public String getLargest() { . . . } /** Gets the middle string in the string set. @return middle the middle string of three strings */ public String getMiddle() { . . . } . . . }
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
import java. util.Scanner; /** This is program sorts three strings. */ public class StringSort { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Please enter three strings:"); String str1 = in.nextLine(); String str2 = in.nextLine(); String str3 = in.nextLine(); StringSet s = new StringSet(str1, str2, str3); System.out.println("The inputs in sorted order are:\n" + s.getSmallest() + "\n" + s.getMiddle() + "\n" + s.getLargest()); } }
Yes..No prbs at all.. I've one more question shall i post it here or in a new question..
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.