[Solved] Output Existing Code Import Javautilscanner Public Class Le62 Static Scanner New Scanner S Q37200947

OUTPUT

EXISTING CODE
import java.util.Scanner;
public class LE62 {
static Scanner in = new Scanner(System.in);
private int size;
void arraySize() {
System.out.printf(“How many inventors? “);
size = Integer.parseInt(in.nextLine());
}
String[] setInventors() {
String []inventors = new String[size];
for(int i=1; i<=size; i++) {
System.out.printf(“%nEnter inventor #%d: “, i);
inventors[i-1] = in.nextLine();
}
return inventors;
}
String[] setInventions(String[] inventors) {
String []inventions = new String[size];
for(int i=1; i<=size; i++) {
System.out.printf(“%nEnter %s’s invention: “,inventors[i-1]);
inventions[i-1] = in.nextLine();
}
return inventions;
}
String[] setInventionYear(String[] inventions) {
String []years = new String[size];
for(int i=1; i<=size; i++) {
System.out.printf(“%nEnter the year in which the %s was invented:”, inventions[i-1]);
years[i-1] = in.nextLine();
}
return years;
}
void printFamousInventors(String []inventors, String[]inventions, String []years) {
System.out.println(“nnFAMOUS INVENTIONS”);
for(int i=1; i<=size; i++) {
System.out.printf(“%nInventor: %s%nInvention: %s%nYear Invented:%sn”, inventors[i-1], inventions[i-1], years[i-1]);
}
}
public static void main(String[] args) {
LE62 x = new LE62();
x.arraySize();
String inventors[] = x.setInventors();
String inventions[] = x.setInventions(inventors);
String years[] = x.setInventionYear(inventions);
x.printFamousInventors(inventors, inventions, years);
in.close();
}
}
Purpose: To learn how to create a class, instantiate an object of the class in another class, and use that object to call methods Prep Work: Read chapter 7. Refer to coding created or reviewed in your IS 2033 class. Name your program as YourLastNameFirstinitialLE71.java. From the code in LE 6.2, do the following 1. You will NOT be changing any of the logic in the code for LE 6.2 2. Create a separate class called Invention. This class ll have NO main0 3. Insert a default constructor in the Invention class. This is a method that is empty and its header looks like this: public NameOfClass() 4. Code an overloaded constructor that will receive a student’s name, when an object for Invention is created in the main0 a. In the Invention class store the student’s name in a field (global variable) called studentAuthor b. You will insert the student’s name in the header of the output 5. Except, for the main0,take all the other methods in LE 6.2 and put them in the Invention class 6. Transfer the fields (class variables) from LE 6.2 to Invention 7. Strip the word static from the fields and the method headers in the Invention class. 8. Cut and paste the main) from LE 6.2 into your program file for LE 7.1 a. Create an object of the Invention class Format Name○Class objectName= new NameOfClass(NameOfStudent) b. Use that object for the method calls in the main0 i. Format objectName.methodName0) 9. Make sure both classes are in the same directory 10. To run both programs, you must run the class with the main) FAMOUS INVENTIONS Report By: Sarah Farrow nventor: Thomas Edison Invention: Tin Foil Phonograph Year Invented: 1877 Inventor: Alexander Graham Bel Invention: Telephone Year Invented: 1876 Inventor: George Washington Carver Invention: Pomade from Peanuts Year Invented: 1925 Show transcribed image text Purpose: To learn how to create a class, instantiate an object of the class in another class, and use that object to call methods Prep Work: Read chapter 7. Refer to coding created or reviewed in your IS 2033 class. Name your program as YourLastNameFirstinitialLE71.java. From the code in LE 6.2, do the following 1. You will NOT be changing any of the logic in the code for LE 6.2 2. Create a separate class called Invention. This class ll have NO main0 3. Insert a default constructor in the Invention class. This is a method that is empty and its header looks like this: public NameOfClass() 4. Code an overloaded constructor that will receive a student’s name, when an object for Invention is created in the main0 a. In the Invention class store the student’s name in a field (global variable) called studentAuthor b. You will insert the student’s name in the header of the output 5. Except, for the main0,take all the other methods in LE 6.2 and put them in the Invention class 6. Transfer the fields (class variables) from LE 6.2 to Invention 7. Strip the word static from the fields and the method headers in the Invention class. 8. Cut and paste the main) from LE 6.2 into your program file for LE 7.1 a. Create an object of the Invention class Format Name○Class objectName= new NameOfClass(NameOfStudent) b. Use that object for the method calls in the main0 i. Format objectName.methodName0) 9. Make sure both classes are in the same directory 10. To run both programs, you must run the class with the main)
FAMOUS INVENTIONS Report By: Sarah Farrow nventor: Thomas Edison Invention: Tin Foil Phonograph Year Invented: 1877 Inventor: Alexander Graham Bel Invention: Telephone Year Invented: 1876 Inventor: George Washington Carver Invention: Pomade from Peanuts Year Invented: 1925
Expert Answer
Answer to OUTPUT EXISTING CODE import java.util.Scanner; public class LE62 { static Scanner in = new Scanner(System.in); private i… . . .
OR

