Write an OOP program that includes a class named "Shape". Next, create two objects from the class; which are "Rectangle" and "Square", Finally, print
Q: Question 2: Implement the ShoppingCart and Product class with necessary properties so that the given…
A: code is here
Q: Write a compareTo method that compares two Song objects based on the artist, and title within…
A: The solution to the given problem is below.
Q: The sections that immediately follow include the definitions of the classes MonthCalender and…
A: DateTimerPicker: 1 This is useful for calculating the worth of a given date and/or time. This is a…
Q: Write a program to accept the length of and width of a rectangle using scanner class and display its…
A: Java has built in Scanner class which enables to accept user input. Java also supports inheritance…
Q: Add the following constructor to your Rectangle class: public Rectangle(Point p, int width, int…
A: Gien: Add the following constructor to your Rectangle class:public Rectangle(Point p, int width, int…
Q: Write an OOP program that include class named "Shape". Which has different variables like; int…
A: Here it is very simple program Create class Name Shape Attribute Length and width as private Set…
Q: In this exercise, you are going to complete the Rectangle class. You need to complete the class so…
A: Java code is as follows:-
Q: Write a class for a Chicken that also implements your interface. The Chicken’s type will be…
A: Here in the section of chicken sound where the condition is that 50 % of time chicken will sound…
Q: To further increase the statistical knowledge of your fight, count the number of times a certain…
A: function countNumberofOccurrences(nums) { //function declaration let a = Object.values(nums)…
Q: Implement a class Car with the following properties. A car has a certain fuel efficiency (measured…
A: public class Car{ public static void main(String[] args){ Car myHybrid = new Car(50);…
Q: Please broadly explain what the code in the driver class does for both of them. What do you think…
A: Please broadly explain what the code in the driver class does for both of them. In 1st driver…
Q: Write a class that instantiates a Scanner object and asks the user for their grade, represented by…
A: Java James Gosling create Java at Sun Microsystems, where it was first released as a key element of…
Q: Print the arrival time of the flight using a combination of methods from Flight and LocalTime • Read…
A: A flight object is created using parameterized constructor and then the changes are made and…
Q: Add the following method to the Point class: public double distance(Point other) Returns the…
A: Solution: Programming language used: Java Program code for distance method - (Note: all…
Q: Drag and drop from the options below to declare an object of type "People", which takes a string as…
A: Declare an object of type "People", which takes a string as the first parameter for its constructor…
Q: Define a class Pet with two attributes, name (a string), and legs (an int). In Pet, define a show…
A: The approach and the python program are given below:Approach:Creating a class Pet.Now, defining the…
Q: Construct a class called Hypixel that will contain all information needed to describe and manipulate…
A: Construction of a class called Hypixel that will contain all information needed to describe and…
Q: Implements an interface having three methods eat, travel, bark in class ANIMAL having three child…
A: Program Plan: Create an interface named Animal In that interface declare methods…
Q: To further increase the statistical knowledge of your fight, count the number of times a certain…
A: In this problem, we are provided with a censored string and a string of the censored vowels. Need…
Q: public abstract class DebugBoat { String boatType = new String(); int passengers; String…
A: public abstract class DebugBoat{ String boatType = new String(); int passengers; String power…
Q: write a program to print the names of the student by creating a student class .if no name is passed…
A: Using Constructor #include <iostream> using namespace std; class Student{ public: string…
Q: Please write an email class using OOP concept to send an email with "Information Technology" for the…
A: -> Everything is explained in code via comments import java.util.*;import javax.mail.*;import…
Q: Write a separate class BookDemo with a main() method that creates a Book object titled “Developing…
A: class Book{ private String name; private String author; private double price;…
Q: Construct an OOP using classes and objects to find the distance travelled by a Vehicle in t" seconds…
A: Logic: Create class and create object. Declare members of the program. Call the method using the…
Q: Implement the ShoppingCart and Product class with necessary properties so that the given output is…
A: Program: Start Create a class ShoppingCart with attributes cart, cartName Implement setCartName()…
Q: Write a program to accept the length of and width of a rectangle using scanner class and display its…
A: Please find the answer below
Q: Write the Python class Lunchltem. Instances of this class represent an item that can also be served…
A: class MenuItem: def __init__(self,name,isVeggie,price): self.name=name…
Q: .Can an object have several different classes? Discuss.
A: An object can have various sorts: the kind of its own class and the kinds of the multitude of…
Q: We need to have a “class” createdcalled ROOMthat has width and lengthdefined. This represents a…
A: Program Approach:- It required class. Display the data members. Display constructor to initialize…
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 test program called TestSquare that: Creates two Square objects: one object with side’s…
A: Since the Programming language is not mentioned in the question, we will answer this question in…
Q: For this assignment, create a child class of car that creates a car of a randomly generated color.…
A: //Adding the package package javafx.swing; //Importing the required header files import…
Q: Exercise 2 - Distance Calculator Inside the Lab2 project, add a new class with the main method…
A: Hello student. Greetings from my side. Hope you are doing great. As per our company's policy, we are…
Q: Given the code below, which statement is incorrect? Choose the best answer. class Artist(): def init…
A: Given code is class Artist(): def init (self, name): self.name = name def namePrint (self): print…
Q: o Add another class for the Square and display its area, users must also input its values needed to…
A: For the Shape Square which is inherited from the interface Shape, we need to take input of a value…
Q: Suppose there is a class Alarm. Alarm has two calss variables, code which contains a String value…
A: I am giving you the code in python
Q: To further increase the statistical knowledge of your fight, count the number of times a certain…
A: In this problem, to further increase your statistical knowledge of your fight, count how many times…
Q: Write a class that instantiates a Scanner object and asks the user for their grade, represented by…
A: Please find the code and screenshot below.
Q: Write a test program called TestSquare that: Creates two Square objects: one object with side’s…
A: Note: Here you didn't mention any programming language so we writing the program in C++ Programming…
Q: Suppose there is a class named Frame with attributes x,and color of type int, String. Override the…
A:
Q: Write a class that instantiates a Scanner object and asks the user for their height, represented by…
A: Your java program is given below as you required with an output.
Q: Write in Java! Write the Widget class. a. A widget has a name and price. b. The default for name…
A: In the Widget class – Take 2 data members named as name and price. Set a default of name with the…
Q: Write a program that animates a small object of your own design, (e.g. a bee, boat, car, plane etc).
A: void setup (){ size (400, 400); //create window} void draw (){ background (255,255,255); //Clear…
Q: Write a program that converts a number entered in Roman numerals to a positive integer. Your program…
A: answer : CODE-- : #include<iostream> #include<iomanip> using namespace std; //class…
Q: Write a test program called TestSquare that: Creates two Square objects: one object with side's…
A: In this question, we are asked to create a test class of the square object in JAVA Code is in the…
Step by step
Solved in 2 steps
- task 14.1 in java Follow these steps:● Create a new java file called MyFile.java● Write code to read the content of the text file input.txt. For each line ininput.txt, write a new line in the new text file output.txt that computesthe answer to some operation on a list of numbers.● If the input.txt has the following:Min: 1,2,3,5,6Max: 1,2,3,5,6Avg: 1,2,3,5,6Your program should generate output.txt as follows:The min [1, 2, 3, 5, 6] is 1.The max of [1, 2, 3, 5, 6] is 6.The avg of [1, 2, 3, 5, 6] is 3.4.● Assume that the only operations given in the input file are min, max andavg and that a list of comma-separated integers always follows theoperation. You should define the functions min, max and avg that take ina list of integers and return the min, max or avg of the list.● Your program should handle any combination of operations and anylength of input numbers. You can assume that the list of input numbersare always valid integers and that the list is never empty.● Compile, save and run…#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/wait.h> int main(){ int i, s; int a[] = {23,4,8,33,25,7,12,6,49,50,11,20,21,24,35}; pid_t pid; pid = fork(); if (pid == 0) { printf("I'm a child, I'll be printing the even numbers:\n"); for(i=0;i<(sizeof(a)/sizeof(int));i++) if(a[i]%2 == 0) printf("%d ",a[i]); } else { printf("I'm the parent, I'll be printing the odd numbers:\n"); if (pid > 0) pid = waitpid(pid, &s, 0); for(i=0;i<(sizeof(a)/sizeof(int));i++) if(a[i]%2 != 0) printf("%d ",a[i]); } return 0;} the output seem to have some error whereby it cannot output the number for the first ifCompulsory Task 1 Follow these steps: ● Create a new java file called MyFile.java ● Write code to read the content of the text file input.txt. For each line in input.txt, write a new line in the new text file output.txt that computes the answer to some operation on a list of numbers. ● If the input.txt has the following: Min: 1,2,3,5,6 Max: 1,2,3,5,6 Avg: 1,2,3,5,6 Your program should generate output.txt as follows: The min [1, 2, 3, 5, 6] is 1. The max of [1, 2, 3, 5, 6] is 6. The avg of [1, 2, 3, 5, 6] is 3.4. ● Assume that the only operations given in the input file are min, max and avg and that a list of comma-separated integers always follows the operation. You should define the functions min, max and avg that take in a list of integers and return the min, max or avg of the list. ● Your program should handle any combination of operations and any length of input numbers. You can assume that the list of input numbers are always valid integers and that the list is never empty. ●…
- Python 3.7.4 Given four files named asiasales2009.txt, europesales2009.txt, africasales2009.txt, and latinamericasales2009.txt, define four file objects named asia, europe, africa, and latin, and use them, respectively, to open the four files for writing.This question concerns the use of a book cypher to encode a message.Write a program called ‘bookcypher.py’ that accepts:1. The file name for a Project Gutenberg book text.2. A message that is to be encoded.3. A file name for output of the encoded version of the message.The program will create an encoded version of the message by replacing its words with the locationsof words in the book.Say, for example, the message is ‘meet me at the usual time and place’, and the Gutenberg text is‘The Importance of Being Earnest’ by Oscar Wilde.• There is an occurrence of ‘meet’ as the 5th word on the 493rd line of the book text.• There is an occurrence of ‘me’ as the 9th word on the 190th line of the text.• There is an occurrence of ‘at’ as the 6th word on the 8th line of the text.• And so on.Representing a word position as a conjunction of the line number and the index of the word withinthe line, we can encode the message as 493-5, 190-9, 8-6, etc.Sample I/O (user input in bold):Enter the book…bubblesort.h is in second picture This is bublesort.c int compare(Entry a, Entry b) {// IMPLEMENT}/*TEST: ./mergesort < test.inOUTPUT:1 lsdfjl2 ghijk3 ksdljf5 abc6 def*/int main(void) {// IMPLEMENT} this is test.in 55 abc6 def2 ghijk3 ksdljf1 lsdfjl
- 5.12.2: Switch statement to convert letters to Greek letters. Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print "Beta". For any other character, print "Unknown". Use fall-through as appropriate. End with newline. import java.util.Scanner; public class ConvertToGreek {public static void main (String [] args) {Scanner scnr = new Scanner(System.in);char origLetter; origLetter = scnr.next().charAt(0); /* Your solution goes here */ }}● Create a Python file called amazon.py in this folder.● Write code to read the content of the text file input.txt.● For each line in input.txt, write a new line in the new text file output.txtthat computes the answer to some operation on a list of numbers.● If the input.txt has the following:o Min: 1,2,3,5,6o Max: 1,2,3,5,6o Avg: 1,2,3,5,6● Your program should generate output.txt as follows:o The min of [1, 2, 3, 5, 6] is 1.o The max of [1, 2, 3, 5, 6] is 6.o The avg of [1, 2, 3, 5, 6] is 3.4.● Assume that the only operations given in the input file are min, max andavg, and that the operation is always followed by a list ofcomma-separated integers.● You should define the functions min, max and avg that take in a list ofintegers and return the min, max or avg of the list.● Your program should handle any combination of operations and anylength of input numbers.● You can assume that the list of input numbers are always valid integersand that the list is never empty.● Hint: there is…C PROGRAM WHEN I RUN IT, I GET THE ANSWER NOT BUILD #include<stdio.h> #include<stdlib.h> #include<process.h> void main() { FILE *fp1, *fp2; char a; clrscr(); fp1 = fopen("infile.txt", "r"); if (fp1 == NULL) { puts("cannot open this file"); exit(1); } fp2 = fopen("outfile.txt", "w"); if (fp2 == NULL) { puts("Not able to open this file"); fclose(fp1); exit(1); } do { a = fgetc(fp1); a = toupper(a); fputc(a, fp2); } while (a != EOF); fcloseall(); getch(); }
- Modify the program 11-10 from pages 753-755 as follows: 1. To Length class files (Length.h and Length.cpp) add the operator overload for stream insertion (<<) and stream extraction (>>) from page 759. You should not use the modified version of class Length from page 759 because it contains more operator overloads. Instead of typing you can use copy/paste from Length1.h and Length1.cpp respectively. 2. In main() replace the lines 11-16 with appropriate usage of stream extraction overload (>>) to change "first" and "second" objects with values inputted by the end user. 3. In main(), replace the output on lines 21,22 and 25,26 with appropriate usage of stream insertion (<<) operator. The resulting output should be identical with the unmodified version of the program. 11-10: // This program demonstrates the Length class's overloaded // +, -, ==, and < operators. #include <iostream> #include "Length.h" using namespace std; int main() { Length first(0),…Follow these steps:● Create a Python file called amazon.py in this folder.● Write code to read the content of the text file input.txt.● For each line in input.txt, write a new line in the new text file output.txtthat computes the answer to some operation on a list of numbers.● If the input.txt has the following:o Min: 1,2,3,5,6o Max: 1,2,3,5,6o Avg: 1,2,3,5,6● Your program should generate output.txt as follows:o The min of [1, 2, 3, 5, 6] is 1.o The max of [1, 2, 3, 5, 6] is 6.o The avg of [1, 2, 3, 5, 6] is 34C Programming Task Write a programme called pgmReduce which takes 3 arguments:1. an input file (either ASCII or binary)2. an integer factor n, and3. an output fileand reduces the input file by that factor in each dimension. For example, if the invocation is:pgmReduce inputFile 5 outputFileand inputFile is a 13x17 image, then outputFile should be a 2x3 image in which only thepixels with row and column of 0 modulo 5 in the inputFile exist