class Vehicle { protected String brand = "Ford"; public void honk() { System.out.println("Tuut, tuut!"); } } // Vehicle attribute // Vehicle method class Car extends Vehicle { private String modelName = "Mustang"; public static void main(String[] args) { // Car attribute
Q: Design a SuperClass named Person with fields for holding a person's name, address, and phone number.…
A: Here is the answer:-
Q: Design the pattern below in the JAVA programming language. R R E R E D R E D O R E D O C
A:
Q: Write a program that prompts the user to input an integer and then outputs both the individual…
A: Note :- As per our guidelines we are supposed to answer only one question. Kindly repost for the…
Q: Create a class SortingAlgorithms with the following methods. o mergeSort that will implement the…
A: The Following Code IS Written In JAVA . class SortingAlgorithms{ private int mergeCtr; private…
Q: Write a program that reads a list of integers, and outputs those integers in reverse. The input…
A: Declare an Array Read Number of Elements Input all the elements Print Number and comma in reverse…
Q: Analyze the following code: public class Test{ public static void main(String[] args) { B b = new…
A: 1) This Java program is a simple example of inheritance and method overloading in Java which defines…
Q: Implement a priority queue using java.util.Stack as the base data type. Your code must not reference…
A: The JAVA code is given below with output screenshot
Q: Suppose a list is (2, 9, 5, 4, 8, 1). After the first pass of bubble sort, the list becomes O2, 9,…
A: The inquiry inquires about the outcome of a bubble sort algorithm's first pass on a given list.…
Q: Which of the following statements are correct?
A: The correct statements are: I: try (PrintWriter output = new PrintWriter("output.txt");) {…
Q: Imagine you are writing a program that stores a student's year (Freshman, Sophomore, Junior, or…
A: We have to write the program for displaying the year of the student, number of courses taken and the…
Q: Given two arrays of integers A[] and B[] of size N and M, the task is to check if a pair of values…
A: The Java code for this problem is given below as:
Q: Problem: Create the classes on the UML class diagram. Set Inheritance relationship between the…
A: import java.io.*; class Student{ private int id; String name; String surname; int getId(){…
Q: Write a program that read an integer, and then finds and prints the sum of the even and odd…
A: As per the requirement program is developed. Note : As per our guidelines we are suppose to answer…
Q: Direction: Create a simple Java Program that will output the grades of 1 student in different…
A: Find Your Answer Below
Q: In java program. Thank you
A: As per the requirement program is completed. Algorithm: Step 1: Write the main() method Step 2:…
Q: Create a program that will compute the simple interest loans in the bank. The program will ask the…
A: import java.util.Scanner;public class JavaExample{ public static void main(String args[]) {…
Q: 2. Create a program that implements all different kinds inhenitance. Use any object to represent…
A: Introdution:There are 6 types of inheritance in total. Single inheritance Multi-level…
Q: Write a program that reads the student information from a tab separated values (tsv) file. The…
A: Required java code along with screenshot f sample output given below :
Q: Fill in the most appropriate code in the blanks in the Myint class? public class Mylnt implements .{…
A: The code defines a class named MyInt that implements the Comparable interface, which allows…
Q: Given the following code: public static void if (n > 100) System.out.println(n); } else mystery2(2 *…
A: Introduction An "if-else" condition is a basic control flow statement in programming languages. It…
Q: Which of the following can be used to replace YYYYYYYY in the following code? public class WildCard…
A: the answer of this question is below Explanation:
Q: In Java please,
A: CODE- import java.io.File;import java.io.IOException;import java.util.Scanner; public class…
Q: Person class has following method for implementation: Person(String name, int age, double height):…
A: According to the information given:- We have to follow the instruction in order to get desired…
Q: Problem: An online grocery store sells items on a web page. A user adds items to a basket and he…
A: Program: import java.util.Scanner;class vat{ public static void main(String args[]) {…
Q: Write methods that implement linear and binary search. Have both methods display the value searched…
A: Algorithm: Start Create an array of size 100 and populate it with elements from 0 to 99. Call the…
Q: What does the following code do? FileInputStream fis = new FileInputStream("test.dat"); It creates a…
A: The question asks to identify the purpose of the given code that creates a FileInputStream for a…
Q: Given the following function: public static int tF(int m, int n) { if (m == 0) return n + 1; else if…
A: In this question, it is asked to predict the output of the given recursive java code The options for…
Q: *6.6 (Display patterns) Write a method to display a pattern as follows: 1 21 3 2 1 n n-1 ... 3 2 1…
A: 1. Input: n (the number of rows for the pattern)2. Initialize variables i, j, and k3. Loop from i =…
Q: Create a recursive method to implement binary search. Call the method from your main program with…
A: The algorithm of the code. 1. Create a function binarySearch with parameters int[] arr, int low, int…
Q: Problem Statement Defining Classes Vrite and document the definition for the Fraction class. The…
A: A class is a group of objects which have common properties. It contains: Fields, Methods,…
Q: Enter a Number: 10 Even Numbers are: 2468 10 Odd Numbers are: 13579
A:
Q: Problem 1: Write an equals method for the Car class. Two cars are equal if they have the same model…
A: public boolean equals(Car c) { if(this.model.equals(c.model) && this.color.equals(c.color))…
Q: Sample Input: The moon shines bright in the midnight sky, As I lay here and wonder why, The stars…
A: The Algorithm of the code:- Step 1: Create a file object and a Scanner object. Step 2: Create a new…
Q: public class Employee { private int hours; private double salary; private int vacationDays; public…
A: a) Java program that implements getHours(),getSalary(),getVacationDays(): class Employee{…
...
in java
Step by step
Solved in 4 steps with 1 images
- public class Stadium extends baseStadium{ public int typeTicket; int floors; int seating; String type; public float ticketPrice; public String leagueName=""; public void SetTecketName(String val) { leagueName=val; } public void setType() { if (typeTicket == 1) { type = "VIP"; } else { type = "Regular"; } } public String getType() { return type; } public void setPrice() { if (typeTicket == 1) { ticketPrice = 250; } else { ticketPrice = 100; } } public void setFloors(int floors) { this.floors = floors; } public int getFloors() { return floors; } public void setSeating(int seating) { this.seating = seating; } public int getSeating() { return seating; } public void printDetails() { System.out.println("Ticket Details:"); System.out.println("Ticket Type:…Public classTestMain { public static void main(String [ ] args) { Car myCar1, myCar2; Electric Car myElec1, myElec2; myCar1 = new Car( ); myCar2 = new Car("Ford", 1200, "Green"); myElec1 = new ElectricCar( ); myElec2 = new ElectricCar(15); } }public class Application { public static void main(String[] args) { Employee empl = new Employee(); empl.firstName = "Ali"; empl.lastName = "Omar"; empl.salary = 20000; Employee emp2 = new Employee(); emp2.firstName = "Mohamed"; emp2.lastName = "Nour"; emp2.salary = 30000; System.out.println("- System.out.printin("- empl.employeeSalary(); System.out.println("- empl.checkEmployeeSalary(emp1.salary, emp2.salary); System.out.printin("- System.out.println("- printEmployee(emp2); System.out.printin("- Employee employeeArr[] = new Employee[2]: employeeArr[0] = empl; employeeArr[1] = emp2; Application a = new Åpplication(); a.printArrayofEmployee(employeeArr); Non static (instance) start to call Static function to print ---------"); "); - Non Static function to print - --"); Non static (instance) start to call same class Static function to print --------); -"); Non Static function to print ----); System.out.println("- System.out.printin("- System.out.printin("Salary : " + Employee.salary);…
- public class Plant { protected String plantName; protected String plantCost; public void setPlantName(String userPlantName) { plantName = userPlantName; } public String getPlantName() { return plantName; } public void setPlantCost(String userPlantCost) { plantCost = userPlantCost; } public String getPlantCost() { return plantCost; } public void printInfo() { System.out.println(" Plant name: " + plantName); System.out.println(" Cost: " + plantCost); }} public class Flower extends Plant { private boolean isAnnual; private String colorOfFlowers; public void setPlantType(boolean userIsAnnual) { isAnnual = userIsAnnual; } public boolean getPlantType(){ return isAnnual; } public void setColorOfFlowers(String userColorOfFlowers) { colorOfFlowers = userColorOfFlowers; } public String getColorOfFlowers(){ return colorOfFlowers; } @Override public void printInfo(){…public class LabProgram { public static void main(String args[]) { Course course = new Course(); String first; // first name String last; // last name double gpa; // grade point average first = "Henry"; last = "Cabot"; gpa = 3.5; course.addStudent(new Student(first, last, gpa)); // Add 1st student first = "Brenda"; last = "Stern"; gpa = 2.0; course.addStudent(new Student(first, last, gpa)); // Add 2nd student first = "Jane"; last = "Flynn"; gpa = 3.9; course.addStudent(new Student(first, last, gpa)); // Add 3rd student first = "Lynda"; last = "Robison"; gpa = 3.2; course.addStudent(new Student(first, last, gpa)); // Add 4th student course.printRoster(); } } // Class representing a student public class Student { private String first; // first name private String last; // last name private double gpa; // grade point average…For the following four classes, choose the correct relationship between each pair. public class Room ( private String m type; private double m area; // "Bedroom", "Dining room", etc. // in square feet public Room (String type, double area) m type type; m area = area; public class Person { private String m name; private int m age; public Person (String name, int age) m name = name; m age = age; public class LivingSSpace ( private String m address; private Room[] m rooms; private Person[] m occupants; private int m countRooms; private int m countoccupants; public LivingSpace (String address, int numRooms, int numoccupants) m address = address; new int [numRooms]; = new int [numOceupants]; m rooms %3D D occupants m countRooms = m countOccupants = 0; public void addRoom (String type, double area)
- class Player { protected: string name; double weight; double height; public: Player(string n, double w, double h) { name = n; weight = w; height = h; } string getName() const { return name; } virtual void printStats() const = 0; }; class BasketballPlayer : public Player { private: int fieldgoals; int attempts; public: BasketballPlayer(string n, double w, double h, int fg, int a) : Player(n, w, h) { fieldgoals = fg; attempts = a; } void printStats() const { cout << name << endl; cout << "Weight: " << weight; cout << " Height: " << height << endl; cout << "FG: " << fieldgoals; cout << " attempts: " << attempts; cout << " Pct: " << (double) fieldgoals / attempts << endl; } }; a. What does = 0 after function printStats() do? b. Would the following line in main() compile: Player p; -- why or why not? c. Could…add override display methodusing System; //base classclass Book{//data membersprivate string title;private string author;protected double price;//constructorpublic Book(string t, string a){title = t;author = a;price = 500;}//method to display detailspublic void display(){Console.WriteLine("Title:" + title + " author:" + author + " price:" + price);}} //child classclass PopularBooks : Book {//constructorpublic PopularBooks(string t, string a) :base(t,a) {price = 50000;}} class Program {static void Main() {//an array of 5 objectsBook[] B = new Book[5];//input title and authorfor(int i=0; i<5;i++){Console.Write("Input title: ");string name = Console.ReadLine();Console.Write("Input author name: ");string author = Console.ReadLine();//if author is popular,//call constructor of sub classif (author.Equals("Khaled Hosseini") || author.Equals("Oscar Wilde") || author.Equals("Rembrandt")){B[i] = new PopularBooks(name, author);}//call base class constructorelse B[i] = new Book(name,…public class Author2 {3 private String name;4 private int numberOfAwards;5 private boolean guildMember;6 private String[] bestsellers;78 public String Author()9 {10 name = "Grace Random";11 numberOfAwards = 0;12 guildMember = false;13 bestsellers = {"Minority Report", "Ubik", "The Man in the HighCastle"};14 }1516 public void setName(String n)17 {18 name = n;19 }20 public String getName()21 {22 return name;23 }2425 public void winsAPulitzer()26 {27 System.out.println(name + " gave a wonderful speech!");28 }29 } 1. This class includes a constructor that begins on line 8; however, it contains an error. Describe the error. 2. Rewrite the constructor header on line 8 with the error identied in part c of this question corrected. 3. Demonstrate how you might overload the constructor for this class. Write only the header. 4. Write a line of Java code to create an instance (object) of this class. Name it someAuthor. 5. Write a line of code to demonstrate how you would use the someAuthor object…
- class IndexItem { public: virtual int count() = 0; virtual void display()= 0; };class Book : public IndexItem { private: string title; string author; public: Book(string title, string author): title(title), author(author){} virtual int count(){ return 1; } virtual void display(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };class Category: public IndexItem { private: /* fill in the private member variables for the Category class below */ ? int count; public: Category(string name, string code): name(name), code(code){} /* Implement the count function below. Consider the use of the function as depicted in main() */ ? /* Implement the add function which fills the category with contents below. Consider the use of the function as depicted in main() */ ? virtualvoiddisplay(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };class Course { private String courseNumber; private String courseName; private int creditHrs; public Course (String number, String name, int creditHrs){ this.courseNumber = number; this.courseName = name; this.creditHrs = creditHrs; } public String getNumber() { return courseNumber; } public String getName() { return courseName; } public int getCreditHrs() { return creditHrs; } public void setCourseNumber(String courseNumber) { this.courseNumber = courseNumber; } public void setCourseName(String courseName) { this.courseName = courseName; } public void setCreditHrs(int creditHrs) { this.creditHrs = creditHrs; }} class Student { private String firstName; private String lastName; private String gender; private String phoneNumber; private String email; private String jNumber; protected ArrayList<MyCourse> courseList; public String…class Course { private String courseNumber; private String courseName; private int creditHrs; public Course (String number, String name, int creditHrs){ this.courseNumber = number; this.courseName = name; this.creditHrs = creditHrs; } public String getNumber() { return courseNumber; } public String getName() { return courseName; } public int getCreditHrs() { return creditHrs; } public void setCourseNumber(String courseNumber) { this.courseNumber = courseNumber; } public void setCourseName(String courseName) { this.courseName = courseName; } public void setCreditHrs(int creditHrs) { this.creditHrs = creditHrs; }}class Student { private String firstName; private String lastName; private String gender; private String phoneNumber; private String email; private String jNumber; protected ArrayList courseList; public String getFullName() {…