Write a java program to print the area and perimeter of a triangle having sides of 3, 4 and 5 units by creating a class named 'Triangle' without any parameter in its constructor.
Q: Java allows implementing multiple interfaces through a single class declaration statement such as:…
A: Whether java allows multiple inheritance throygh single declaration statement.
Q: Write one java code program with a class whose instances represent a single playing card from a deck…
A: public class Main{ public static void main(String[] args) { Card c1=new Card(); //create Card…
Q: Create a java program for a student details for displaying student information and student Grade…
A: import java.util.*;import java.lang.*;import java.io.*; class Student{ private String name;…
Q: Write a Java program with the following: A method with name display to display the average time,…
A: Programming instructions: Include necessary header files. Create required variables. Create a…
Q: Write a class in java with the name AgeMessages , which does the following: a. Ask the user to enter…
A: Java program to solve the given problme is below.
Q: Write the main class of this Java program vending machine
A: Our java vending machine looks like:
Q: Write a java program that shows a square frame filled with 10 buttons labeled 1 to 10, when one of…
A: import javax.swing.*; import java.awt.*;import java.awt.event.*; public class Main implements…
Q: For Java Programming: Write a class encapsulating the concept of a course grade, assuming a course…
A: //CourseGrade.javapublic class CourseGrade { private String name; private char letterGrade;…
Q: Consider a class PersonAddress that represents an entry in an address book. Its attributes are The…
A: ANSWER:-
Q: Write a java program A class called Book, It contains: (15 Marks) • Five instance variables:…
A: It is defined as the can be asked from control statements, array, string, oops etc. Java basic…
Q: Write a JAVA program with class name as Exam using Mutable objects to calculate the volume of…
A: Volume is three-dimensional space and is denoted by a standard unit of “meter” in physics. Volume…
Q: Write 2 Java classes for a task to compute the area of a right triangle. The first Java class has…
A: import java.util.Scanner; public class UsingRightTriangle{ public static void main(String[] args) {…
Q: Write one java program with a class whose instances represent a single playing card from a deck of…
A: Actually, java is an object oriented programming language. It is a platform independent.
Q: Write a Java program that creates and displays the following GUI. (In this problem there is no need…
A: package javafxapplication1; import javafx.application.Application;import…
Q: Write a Java program that reads five products' prices and then displays the total before and after…
A: I give the code in Java along with output and code screenshot
Q: te a calculator in Java with a menu that loops back if the user wants to try again
A: I have given the java code for the calculator below.
Q: Create a cashiering system in Java that applies the OOP concept. There should be a receipt that will…
A: Object Oriented Concept uses class and object in which class refers to a blueprint or template which…
Q: a test class) to represent some real-world entity such as a technology item (TV, Fan etc), an…
A: given - Create a Java Project (with a class and a test class) to represent some real-world entity…
Q: Write a java program to print the area of a rectangle by creating a class named 'Area' having two…
A: The required Java code is given below: import java.util.Scanner;public class Area{ // class Area…
Q: Write a program called TimeConvertor.java that converts times expressed in 24-hour clock to 12-hour…
A: A required Java program is as follows, File name: "TimeConvertor.java" // Import the necessary…
Q: Write a java program to print the area of a rectangle by creating a class named 'Area' taking the…
A: java program to the given problem:
Q: Implement using Java Create an interface that shall have 2 methods and one string type attribute,…
A: I have added the comments in the code. Also, make sure to give the java file name Demo.java. If you…
Q: B - Write a program in java to create a class for students that contains the student's name and…
A: Student.java:- public class Students { private String studentName; private char grade;…
Q: Develop a java program to print a receipt for the tuition fee payment. Define a class TuitionFee…
A: I give the code in Java along with output and code screenshot
Q: Write a class in java with the name AgeMessages , which does the following:a. Ask the user to enter…
A: The algorithm for the program would be as below:Declare one float variable for accepting user…
Q: calculator applying the OOP concepts in Jav
A: Below the basic or complex calculator applying the OOP concepts in Java
Q: Write a Java program containing two classes: Dog and a driver class Kennel. The Dog class consists…
A: public class Dog { int age; String name; boolean hairLength; enum tail { LONG,…
Q: Create a java program that computes the perimeter of a square, reactangle and the circumference of a…
A: Overriding is a feature that allows a subclass or child class to provide a specific implementation…
Q: design a program in java to draw objects from polygon class and present a JFrame with the 3 initials…
A: Program Code: LinesRectsOvalsJPanel.java import java.awt.Color;import java.awt.Graphics;import…
Q: Write a Java program that has a class named TEST2 which contain the method named SUM1 to find the…
A: Here I have created a function named SUM1(). This function iterates over the list of numbers and…
Q: Write a program in java . Create a class names “A” with a method to print “ method of class A”.
A: public class A { //creating a class name A public void…
Q: Implementation: A Java package with the name "Quiz2" is created with a class named "Geometry". In…
A: Your java program is given below as you required with an output.
Q: Write a program to print the area of rectangle by creating a class named "Rectangle" with…
A: public class Main{ public static void main(String[] args) { Rectangle r1=new Rectangle(12,13);…
Q: Write a Java program containing two classes: Dog and a driver class Kennel. The Dog dlass consists…
A: Given :- Write a love program containing two classes: Dog and a driver class Kennel.Dog class…
Q: Create a Java Project (with a class and a test class) to represent some real-world entity such as a…
A: The complete answer in Java Programming Language is below: we are taking example of person.
Q: Write a program that uses a bar chart to display the percentagesof the overall market share…
A: Program: //Import required packagesimport javafx.application.Application;import…
Q: Write a java class called House with the following two private attributes, and three methods:…
A: The classes House and HouseMap are given below and their formatted image version: public class…
Q: Write a class in java with the name AgeMessages, which does the following: a. Ask the user to enter…
A: INTRODUCTION: In the given code statement, we are asked to create one java class and naming it as…
Q: Complete the TrafficLightComponent class to draw a traffic light such as this one. The rectangle…
A: Program: File name: “TrafficLightComponent.java” //Import necessary packages import java.awt.Color;…
Q: Write a Java program for a class called MyPoint, which models a 2D point with x and y coordinates,…
A: A class called MyPoint, which models a 2D point with x and y coordinates, is designed as shown in…
Q: Submit any simple java project which uses any inner class type.
A: Lets see the solution.
Q: Create a Java Project (with a class and a test class) to represent some real-world entity such as a…
A: We'll use a real-world animal to fulfill all of the conditions.
Q: Write a java program to create a class 'simpleobject". Using constructor to display the message
A: Lets see the solution.
Q: Create a java program with a class whose instances represent a single playing card from a deck of…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write a Java program that reads five products' prices and then displays the total before and after…
A: Solution: Formula for Discount D = Summed of Prices * How much Percentage / 100
Q: Write a java program to print the area of two rectangles having sides (4,5) and (5,8) respectively…
A: Input : In input, the object of the Rectangle class is created. In object creation, the…
Q: Write one java code program with a class whose instances represent a single playing card from a deck…
A: Required: Write one java code program with a class whose instances represent a single playing card…
Q: 1. Write a java program where Mobile is a class, which has some attributes like Profile Type, IME…
A: The only first question will be answered. Java program: //creating class Mobileclass Mobile{…
Q: Write a program to print the area of a rectangle by creating a class named 'Area' having two…
A: Java program to print the area of a rectangle. The name of the class is Area. This class has two…
Q: Write a java program in a class CountPoor that counts the number of families that are considered…
A: A family is said to be poor if it struggles or is not able to pay for all it's expenses, thus it has…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- In java language Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle object by providing the width and length in that order. If no width and length are provided to the constructor, construct a Rectangle with width 0.0 and length 0.0. We want to be able to get and set both the width and the length independently. We also want to be able to ask for the area of the rectangle and the perimeter of the rectangle. What will the object need to remember? width and length - those are the instance variables. Rectangle class has these constructors : public Rectangle() - Constructs a new rectangle with width and length of 0.0. public Rectangle(double width, double length) - Constructs a new rectangle with the given width and length. Remember that the job of the constructor is to initialize the instance variables. It has these methods. public double getWidth() - Gets the width of this Rectangle public double getLength() - Gets the length of this…Write a program using java programing language. Write a Java class (called ShowNum) that displays the same number of asterisks (row and columns) as is input in 2 numbers. Your class should have a default constructor (number1 is 0, number2 is 0) and another constructor that inputs 2 numbers (integers). You'll need accessor methods for the numbers and a display method that displays as follows: Input: 2, 7 ******* ******* Demo the class in a client (called ShowNumClient) that allows the user to run the program as many times as they want (enter number and use display method). The user will signal with a sentinel (-1), when they want to terminate the client. Make sure that each number entered in the client is between 1 and 30.1. Implement the following classes and interface in Java.• Shape interface which has the following methods:– public double perimeter(); // doesn’t have any parameters, returns the perimeter of the shape.– public double area(); // doesn’t have any parameters, returnsthe area of the shape.– public void info(); // doesn’t have any parameters, prints theperimeter and area of the shape.• Circle class that implements Shape interface and has a constructorthat takes the radius.• Rectangle class that implements the Shape interface and has a constructor that takes the width and height.• Square class that extends the Rectangle class and has a constructorthat takes the edge length.– Square constructor should only call the super constructor withcorrect parameters.– Square constructor should not explicitly implement the Shapeclass, but it should inherit the perimeter, area and info methodsfrom the Rectangle class.2. Create a Test class, and create one Circle, one Rectangle and one Squareobjects.…
- in JAVA Assume that a receipt id contains characters that represent information or that can be used as a code to determine something about the purchase. For example: if an id has an 'x' followed by two 'y's, it means that the purchase was a final sale and cannot be returned. Or if an id has an 'a' followed by three 'b's, it means that a coupon was used for purchase. Write a static method for the Receipt class to test whether a receipt id meets such a criteria. Does the id meet the criteria? The criteria is described by three pieces of data, passed in as parameters: char firstTarget char second Target int countOfSecond After First A receipt id meets the criteria if: the id contains the first target character and the second target character appears exactly the specified number of times after the first target character appears Note: the first and second char could be the same char! Carefully review the provided driver program for examples of ids that meet and don't meet criteria. For full…in java create a class called publication that stores the title (a string) and price (type float) and date of a publication. Provide getters/setters and constructor also write an abstract method isOversize() .From this class derive two classes: book, which adds a page count (type int); and tape, which adds a playing time in minutes (type float). Each of the classes should have a getter/setters and constructors and provide definition to function called isOversize() to the book and tape classes. Let’s say that a book with more than 800 pages, or a tape with a playing time longer than 90 minutes (which would require two cassettes), is considered oversize. You can access this function from main() and display the string “Oversize” for oversize books and tapes when you display their other data.in Java language : Write a program to print the area of a rectangle by creating a class named “Rectangle” with constructor having the two sides (width and height) as its parameters Test the class by creating a main class which contains the main method -->name the class “TestRectangle” Use the Scanner library to take the two sides as inputs from the console.
- Write Java code for a Baby class. A Baby has a name of type String and an ageof type integer.Supply two constructors: one will be the default constructor, that just setsdefault values for the name and age; the second constructor will take twoparameters, a string to set the name and an integer to set the age. Also, supplymethods for setting the name, setting the age, getting the name and getting theage.The class should not contain I/O methods; input of values to the instancevariables must be done with a set method or constructor, output of values fromthe instance variables must be done with get methods. The set method for thename instance variable should ensure that the input is not empty or containwhitespaces (otherwise set a default value). The set method for the ageinstance variable should validate the input to be between 1 and 4 inclusive(otherwise set a default value).Give Java code for an equals method for the Baby class. Babies count asbeing the same (i.e. equal) if their names…Build a Java class named Bag. This bag is unique; each item in this class comprises three randomly generated letters that are unfamiliar to both the consumer and programmer (a-z lowercase). Additionally, the Bag class includes a method named GrabLetter that accepts an integer n (0,1, or 2) as a parameter and returns one of the random letters it contains based on the value of n. (passing the same integer to the same Bag object twice should yield the same letter). If the integer passed to every bag is not 0, 1, or 2, it always returns '?'. (Make use of the transfer statement.)In Java Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes:• circles• rectangles• cylinders Here are the formulas for calculating the area of the shapes.Area of a circle: Area = πr2where π is Math.PI and r is the circle’s radiusArea of a rectangle: Area = Width x LengthArea of a cylinder: Area=5 πr2hwhere π is Math.PI, r is the radius of the cylinder’s base, andh is the cylinder’s heightBecause the three methods are to be overloaded, they should each have the same name, butdifferent parameter lists. Demonstrate the class in a complete program.
- Write a java program to create a class circle class with radius as data member. Create two constructors (no argument, and two arguments) and a method to calculate Circumference.Write a Java program for a class named Baby. A Baby has a name of type String and an ageof type integer.Supply two constructors: one will be the default constructor, that just setsdefault values for the name and age; the second constructor will take twoparameters, a string to set the name and an integer to set the age. Also, supplymethods for setting the name, setting the age, getting the name and getting theage.The class should not contain I/O methods; input of values to the instancevariables must be done with a set method or constructor, output of values fromthe instance variables must be done with get methods. The set method for thename instance variable should ensure that the input is not empty or containwhitespaces (otherwise set a default value). The set method for the ageinstance variable should validate the input to be between 1 and 4 inclusive(otherwise set a default value).Give Java code for an equals method for the Baby class. Babies count asbeing the same (i.e. equal) if…A shop wants to automate the purchase of products using a Java program and both class and method concepts. A product is described by at least 4 properties including the available quantity and the price. It has two methods: one for purchasing a given product in given quantity and another one for displaying the updated details of the product. Choose one product of your choice and complete the following tasks: 1. Write the Java class for the product of your choice as specified above. Note: The method for purchasing a given quantity must check first if that quantity is available or not.2. Write the principal program that starts by initializing the product details and then asks the user on the quantity to purchase. The program calls the object method for making the purchase and then displays the updated details of the product by calling the method Display().