subject

Instrument information (derived classes) Given main() and the Instrument class, define a derived class, String Instrument, for string instruments. Ex. If the input is: Drums Zildjian 2015 2500 Guitar Gibson 2002 1200 19 the output is: the output is: Instrument Information: Name: Drums Manufacturer: Zildjian Year built: 2015 Cost: 2500 Instrument Information: Name: Guitar Manufacturer: Gibson Year built: 2002 Cost: 1200 Number of strings: 6 Number of frets: 19 File is marked as read only Current file: InstrumentInformation. java 1 import java. util. Scanner; public class Instrument Information { public static void main(String[] args) { Scanner scnr = new Scanner(System. in); Instrument my Instrument = new Instrument(); String Instrument myString Instrument = new StringInstrument(); String instrumentName, manufacturerName, string InstrumentName, stringManufacturer; int yearBuilt, cost, stringYearBuilt, stringCost, numStrings, numFrets; instrumentName = scnr. nextLine(); manufacturerName = scnr. nextLine(); yearBuilt = scnr. nextInt(); scnr. nextLine(); cost - scnr. nextInt(); scnr. nextLine(); stringInstrumentName = scnr. nextLine(); stringManufacturer = scnr. nextLine(); stringYearBuilt = scnr. nextInt(); stringCost = scnr. nextInt(); numStrings = scnr. nextInt(); numFrets = scnr. nextInt(); my Instrument. setName(instrumentName); my Instrument. setManufacturer (manufacturerName); my Instrument. setYearBuilt(yearBuilt); my Instrument. setCost(cost); my Instrument. printInfo(); myStringInstrument. setName(string InstrumentName); myString Instrument. setManufacturer(stringManufacturer) ; myString Instrument. setYearBuilt(stringYear Built); myString Instrument. setCost(stringCost); myString Instrument. setNumOfStrings (numStrings); myString Instrument. setNumOffrets(numFrets); myString Instrument. printInfo(); System. out. println(" System. out. println(" Number of strings: " + myString Instrument. getNumOfStrings()); Number of frets: " + myString Instrument. getNumOffrets()); 43 } File is marked as read only Current file: Instrument. java- public class Instrument { protected String instrumentName; protected String instrument Manufacturer; protected int yearBuilt, cost; public void setName(String userName) { instrumentName = userName; public String getName() { return instrumentName; public void setManufacturer(String userManufacturer) { instrumentManufacturer = userManufacturer; public String getManufacturer() { return instrumentManufacturer; public void setYear Built(int userYearBuilt) { yearBuilt = userYearBuilt; public int getYearBuilt() { return yearBuilt; public void setCost(int userCost) { cost = userCost; public int getCost() { return cost; public void printInfo() { System. out. println("Instrument Information: "); System. out. println(" Name: " + instrumentName); System. out. println(" Manufacturer: " + instrumentManufacturer); System. out. println(" Year built: " + yearBuilt); System. out. println(" Cost: " + cost); Current file: StringInstrument. java Load default template... 1 // TODO: Define a class: String Instrument that is derived from the Instrument class 2 public class String Instrument extends Instrument { // TODO: Declare private fields: numStrings, numFrets // TODO: Define mutator methods - // setNumOfStrings(), setNumOffrets() 9 // TODO: Define accessor methods - // getNumOfStrings(), getNumOffrets() 13

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Eva has many contacts on the professional networking site she uses which contacts are considered second degree
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 02:00
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
An english teacher would like to divide 8 boys and 10 girls into groups, each with the same combination of boys and girls and nobody left out. what is the greatest number of groups that can be formed?
Answers: 2
You know the right answer?
Instrument information (derived classes) Given main() and the Instrument class, define a derived cla...
Questions