Look at the following declaration:enum Flower { Rose, Daisy, Petunia } In memory, what value will be stored for the enumerator Flower.Rose? ForFlower.Daisy? For Flower.Petunia?
Q: You are required to design an item class which has following attributes String name;…
A: The program is written in java
Q: TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create…
A: TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create…
Q: Fill-in-the-Blank A constructor whose parameters all have default values is a(n) _________…
A: Given;- A constructor whose parameters all have default values is a(n) _________ constructor.
Q: The friend function contradicts the purpose of encapsulation. Also, discuss the many applications…
A: Introduction: Although the friend function is in violation of the encapsulation, this is…
Q: Write a program that uses a structure to store the information about the Items in a retail store. It…
A: //Solution: //class Itempublic class Item { //declaring the class variables String name; final…
Q: Fill-in-the-Blank Constructors cannot have a(n) _________ type.
A: Answer: Constructors cannot have a(n) _________ type.
Q: ava program Car Maintenance: This assignment will assess your understanding of void and value…
A: Program: import java.util.Scanner; public class Main { //method carMaintenance //takes…
Q: The __________ creates an object in memory and returns a reference to that object. a. = operator b.…
A: ANS: - Option(c) is correct. The new operator creates an object in memory and returns a reference to…
Q: How can you initialize an array of a class type with references to objects of the class?
A: To develop a program which can initialize an array of a class type with references to objects of the…
Q: What is a copy constructor's purpose?
A: Introduction: A copy constructor is a class member function that initialises an object with another…
Q: True or False Objects that are instances of a class can be stored in an array.
A: To evaluate whether the given statement is true or false let us consider an example of a class…
Q: Assume you have a system with the following (As in the picture) write the following in c++ (using…
A: The given system can be implemented using inheritance as follows: Class Region will act as an…
Q: A class caled rope defined an integer attribute called length. The default value for length is 100…
A: Program Approach:- 1. Include header file 2. Create the class rope 3. Data Member is:- int length…
Q: Write a class called Game that contains a video game's name, genre, and difficulty Level. Include a…
A: According to the information given:- We have to create Game class for video game with its name and…
Q: Assignment 2: - Create the first Apex class or program -- In this apex class, we have to create 2…
A: Create the first Apex class or program-- In this apex class, we have to create 2 methods-- In the…
Q: 6. Driver's License Exam The local Driver's License Office has asked you to write a program that…
A: import java.io.*;public class DriverExam{ public static int totalIncorrect(String answer[],String…
Q: You have to design your own java console application about any valid problem that your application…
A: Coded using Java.
Q: Once an object name is declared, can it be reassigned to reference another object?
A: Once an object name is declared, can it be reassigned to reference another object?
Q: Attributes item_name (string) item_price (int) item_quantity (int) Default constructor Initializes…
A: The complete JAVA program is given below with code and output screenshots Happy Coding?
Q: User Class ATTRIBUTES NOTE: The important method has been given to you. userld:int //generates…
A: Class is a user-defined data type that can store the different types of the data values like…
Q: This is the default value for fields declared to "hold" object instances.
A: Here the question is related to the default value for fields declared to hold object instances.
Q: please use c++ to answer the following question Task 7: Use inheritance and classes to represent a…
A: C++ is a general-purpose programming language designed as an expansion of the C programming…
Q: 1- When making a class instance, the default constructor of its fields is invoked. (True or False)…
A: The question is to answer the given three questions related to C++.
Q: n this assignment, you will implement the following class. Point3D: Represents the three-dimension…
A: I'm writing C++ code for the following question.
Q: In this lab, you create a derived class from a base class, and then use the derived class in a…
A: Requirement- In this lab, you create a derived class from a base class, and then use the derived…
Q: TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create…
A: Solution: Given, In Python, modify the given code based on the given specifications below.…
Q: In this exercise, you will be completing part of the MortgageCalc class. The MortgageCalc class is a…
A:
Q: Fill-in-the-Blank __________ is the default behavior when an object is assigned the value of another…
A: Given:- Fill-in-the-Blank __________ is the default behavior when an object is assigned the value…
Q: 1.Use inheritance and classes to represent a deck playing cards. Create a Card class that stores the…
A: OOP'S concept: It is the backbone of programming language. It includes following categories…
Q: Fill-in-the-Blank A(n) _________ constructor is one that requires no arguments.
A: Answer: A(n) _________ constructor is one that requires no arguments.
Q: What do you know about Compile time and Run time Polymorphism along with Code(Console based) Example
A: In java programming language, there are two types of polymorphism: 1. Compile time polymorphism also…
Q: Create a generic pet, and print the pet's information using print_info(). Create a Dog pet, use…
A: Approach: Creating generic pet (using pet_name, pet_age) and then calling method print_info()…
Q: Write a class called Game that contains a video game’s name, genre, and difficulty Level. Include a…
A: The answer given as below:
Q: Is it always necessary to create objects from class
A: Question. Is it always necessary to create objects from class. Answer. Objects: An object refers to…
Q: What exactly do you mean by static data member and static memberfunction?
A: In the C and C++ programming languages, the keyword static is used. Inside and outside of the class,…
Q: What is the purpose of a copy constructor?
A: Copy constructor The copy constructor is a constructor which creates an object by initializing it…
Q: What are the three things that you are required to perform for classes that include member variables…
A: Each class that contains a pointer data member must implement the following member functions: a…
Q: 2- How to access data members of a class? a) Dot operator b) Arrow operator c) Dot or arrow as…
A: The data members and member functions of class can be accessed using the dot('. ') operator with the…
Q: When is a copy constructor called?
A: Given:- When is a copy constructor called?
Q: // P63.cpp - This program is a driver written to demonstrate how the constructor function works.…
A: Introduction of the Program: The C++ program illustrates the concept of constructor. A constructor…
Q: Fill-in-the-Blank A constructor is automatically called when an object is _________.
A: Create
Q: What is the difference between a move constructor and a copy constructor?
A: Answer: Constructor is used to construct and initialize all data members and constructors are…
Q: I need the source code for this question 4 in Java. Please provide an explanation for the methods…
A: Change.java import java.util.ArrayList; public class Change {private String name;private int change,…
Q: True or false: The default constructor is the only constructor that may be called for objects in an…
A: Given: Default constructor is the only constructor that may be called for objects in an array of…
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
Look at the following declaration:
enum Flower { Rose, Daisy, Petunia } In memory, what value will be stored for the enumerator Flower.Rose? For
Flower.Daisy? For Flower.Petunia?
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- In previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing Dancing, Musical instrument, and Other. The class contains an auto-implemented property that holds a contestants name. The class contains fields for a talent code and description. The set accessor for the code assigns a code only if it is valid. Otherwise, it assigns I for Invalid. The talent description is a read-only property that is assigned a value when the code is set. Modify the GreenvilleRevenue program so that it uses the Contestant class and performs the following tasks: The program prompts the user for the number of contestants in this years competition; the number must be between 0 and 30. The program continues to prompt the user until a valid value is entered. The expected revenue is calculated and displayed. The revenue is $25 per contestant. The program prompts the user for names and talent codes for each contestant entered. Along with the prompt for a talent code, display a list of the valid categories. After data entry is complete, the program displays the valid talent categories and then continuously prompts the user for talent codes and displays the names of all contestants in the category. Appropriate messages are displayed if the entered code is not a character or a valid code.Assume you have a system with the following (As in the picture) write the following in c++ (using Inheritance) and make menu Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. Create array of countries called Arab of 22 countries. Write a function fill that fills the array Arab Write a method that finds the city that has the max area in a country Write a method that sorts the cities in a country from the largest to the smallest areaAssume you have a system with the following (As in the picture) write the following in c++ (using Inheritance) and make menu Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. Create array of countries called Arab of 22 countries. Write a function fill that fills the array Arab Write a method that finds the city that has the max area in a country Write a method that sorts the cities in a country from the largest to the smallest area Write a function that returns array of countries of the same area of Arab Write a function that compares between two countries. It returns true if country1 area greater than country2 area. Write a function to move a city from one country to another.
- Java program Car Maintenance: This assignment will assess your understanding of void and value returning static methods. Your cousin owns an automotive maintenance shop that performs routine maintenance on cars. He has asked you to write a program that will provide a list of services (and their respective prices) to users and allow them to choose any, or all, services they would like and display the final price, including a 28% labor charge, a 9% markup if the car is an import, and an 8% sales tax. Task To accomplish the above, do the following: • Write the two methods outlined below. • Test your program and screenshot your successful test. carMaintenance method This method should accept the make of the car as a parameter (e.g., BMW, Ford, Ferrari, etc.). It should display the services and their prices as follows: Services: Oil Change, Tune up, Brake Job, Transmission Service, respectively: 59.99, 111.99, 189.99, 149.99 These should be stored in parallel arrays. Ask the user to…Look at the following declaration:enum Flower { Rose, Daisy, Petunia } What is the name of the data type?Magic Squares One interesting application of two-dimensional arrays is magic squares. A magic square is a square matrix in which the sum of every row, every column, and both diagonals is the same. Magic squares have been studied for many years, and there are some particularly famous magic squares. In this exercise you will write code to determine whether a square is magic. File Square.java contains the shell for a class that represents a square matrix. It contains headers for a constructor that gives the size of the square and methods to read values into the square, print the square, find the sum of a given row, find the sum of a given column, find the sum of the main (or other) diagonal, and determine whether the square is magic. The read method is given for you; you will need to write the others. Note that the read method takes a Scanner object as a parameter. File SquareTest.java contains the shell for a program that reads input for squares from a file named magicData and tells…
- Write an application in C++ using simple code that uses a class called “Book” (seedetails below). The application must perform the following tasks. Create an array of “Book” objects (i.e., array must be able to store 2books). Create 2 “Book” objects initialized as follows.o title = “C++ Textbook”; Author = “Pete Parker”; Publisher =“Cengage”, ISBN = “0123456789”; subject = “Computer Programming”;o title = “Java Textbook”; Author = “Bruce Wayne”; Publisher = “McGrawHill”, ISBN = “9876543210”; subject = “Computer Programming”; Add the two books to the array.o Assume the two publishers have merged into a new company called“BookConglomerate”. Use a loop to create statements to modify thepublisher field with the new publisher name. Display the following information for both bookso Book Title (i.e., “C++ Textbook” or “Java Textbook”)o Authoro Publishero ISBNo SubjectThe Book class must contain the following. Constructor with parameters that initialize all instance variables title,…Class Student This class represents a single student __init__(self, id: int, fist_name: str, last_name: str, town:str): """ This creates a student object with the specified ID first and last name and home town. This constructor should also create data structure for holding the students grades for all of there assignments. Additionally it should create a variable that holds the student's energy level which will be a number between 0 and 1. The student start out with 1 (100%) energy. :param id: The student's identifiaction number :param fist_name: The student's first name :param last_name: The student's last name :param town: The student's home town """ get_id(self)->int: """ Returns the ID of the student as specified in the constructor. :return: The student's ID """ get_first_name(self) -> str: """ Returns the first name of the student. :return: The student's first name """ set_first_name(self, name:str):…TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create another class, “Food.” For the Food class, the specifications are: The object will have the following attributes on initialization: weight (weight of the food in kg) energy_add (amount of energy it will add once consumed) happiness_add (amount of happiness it will add once consumed) Modify the Child and the Friends classes such that: Instead of accepting a string (as food) in the eat method, the method should accept a Foodobject Once a Child/Friendsobject eats a Food object: The added weight should be the Food object’s weight The added energy should be the Food object’s energy_add The added happiness should be the Food object’s happiness_add The given code (can also be found on the picture): class Child: def __init__(self, child_number: int, name: str, weight: float): self.child_number = child_number self.name = name self.weight = weight def…
- TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create another class, “Food.” For the Food class, the specifications are: The object will have the following attributes on initialization: weight (weight of the food in kg) energy_add (amount of energy it will add once consumed) happiness_add (amount of happiness it will add once consumed) Modify the Child and the Friends classes such that: Instead of accepting a string (as food) in the eat method, the method should accept a Foodobject Once a Child/Friendsobject eats a Food object: The added weight should be the Food object’s weight The added energy should be the Food object’s energy_add The added happiness should be the Food object’s happiness_add After modifying the Child and Friends behavior, simulate a small group of Friends. In the main code, do the following: Accept a positive integer from the user that determines the number of friends and create a number of Friends specified…Code a called method that takes two parameters, an array of double as reference type and a double value. In the method, manipulate the argument by incrementing the value of the array. Note that you are not required to manipulate the entire array.Mortgage Calculator In this exercise, you will be completing part of the MortgageCalc class. The MortgageCalc class is a class containing static methods to help calculate elements related to home loans, such as a payment calculator, principal payment calculator, and a remaining principal balance calculator. You will write two methods of the class. public class MortgageCalc { /** * This method calculates the monthly payments for a mortgage payment * @param principal Initial amount of the loan * @param numPayments number of months in the loan * @return the monthly payment for the loan */ public static double payment(double principal, int numPayments) { /* To Be implemented in part A */ } /** * This method returns the remaining balance for a given month * in the loan. * @param originalBal original balance of the loan * @param numPayments original number of months in the loan * @param currPeriod the month to calculate the remaining balance * @return the remaining balance on the…