Question

IS 2031: LE 7.1 Lab Day DUE D M 4/22/19 Sections 001, 002, 003 Purpose: To learn how to create a class, instantiate an objectcswebdav/pid 3-dt-forum-rid-61474930, -11277 courses/ISA 201920/Chapter%20 SAMPLE OUTPUT**** How many inventors? 3 Enter inve

0 0
Add a comment Improve this question Transcribed image text
Answer #1

[Note: Since LE 6.1 is not provided I have created the program according to my understanding]

Program

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Invention {
   //global variable
   private String studentAuthor;
   public Invention() {}//default constructor
   public Invention(String studentAuthor) {//overloaded parameterized constructor
       this.studentAuthor = studentAuthor;
   }
   public String getStudentAuthor() {//getter
       return studentAuthor;
   }
   public void setStudentAuthor(String studentAuthor) {//setter
       this.studentAuthor = studentAuthor;
   }
}
public class Test {
   public static void main(String[] args) throws IOException {
       //for taking console input
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       //taking inputs
       int size;
       System.out.print("How many inventors? ");
       size = Integer.parseInt(br.readLine());
      
       int[] year = new int[size];
       String[] inventors = new String[size];
       String[] invention = new String[size];
       System.out.println();
       for(int i=0; i<size; i++) {//taking inventors input
           System.out.print("Enter inventor #"+(i+1)+": ");
           inventors[i] = br.readLine();
           System.out.println();
       }
       for(int i=0; i<size; i++) {//taking inventions input
           System.out.print("Enter "+inventors[i]+" invention: ");
           invention[i] = br.readLine();
           System.out.println();
       }
       for(int i=0; i<size; i++) {//taking years input
           System.out.print("Enter the years in which "+invention[i].toLowerCase()+" was invented: ");
           year[i] = Integer.parseInt(br.readLine());
           System.out.println();
       }
       //showing output
       Invention obj = new Invention("Sarah Farrow");//setting name of Student author
       System.out.println();
       System.out.println("FAMOUS INVENTIONS");
       System.out.println("Reported By: "+obj.getStudentAuthor());
       System.out.println();
       for(int i=0; i<size; i++) {
           System.out.println("Inventor: "+inventors[i]);
           System.out.println("Invention: "+invention[i]);
           System.out.println("Year Invented: "+year[i]);
           System.out.println();
       }
   }
}

Program Screenshot

Test.java 1 import java.io.BufferedReader 2 import java.io.IOException; 3 import java.io.InputstreamReader; 4. 5 class Invent

Output

<terminated> Test (1) [Java Application] CAProgram FilesJava\jre1.8.0_181\binljavaw.exe (22-Apr-2019, 12:55:49 PM How many in

Add a comment
Know the answer?
Add Answer to:
IS 2031: LE 7.1 Lab Day DUE D M 4/22/19 Sections 001, 002, 003 Purpose: To...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT