3.8 Exercise 1: write class Student and StudentTest <> © Student (default package) o id: int o fName: String O IName: String Student(int) fStudent(int, String, String) getld():int o stld(int):void • getfName():String setfName(String):void • getIName():String setIName(String):void • DisplayMessage():String Private states 2 constructors™ Public bihaviors
Q: Define a new "Degree" class that contains a year (integer), a subject (string), and a person’s name…
A: We need to code the degree class as per the given data.
Q: QUESTION 4 einclude ciostrea using nanespace std class Quad private double height double base 10 11…
A: memory is allocated to a class only when its object is created. Here in the question, in line number…
Q: class Duration: def_init (self, hours, minutes): self.hours hours self.minutes minutes def_add_…
A: We have to find output of the given Code
Q: 2] What is the output of the following code? plic class Test { ublic static void main(String[] args)…
A: Ans: Explanation: 1. Using the class name as the test 2: Beginning of main () 3: Declaring and…
Q: mplement the copy constructor and copy assignment operator of the derived class Runner in a way that…
A: A copy constructor is a member function that initializes an object using another object of the same…
Q: Task – 8 Implement the design of the FootBallTeam and the CricketTeam classes that inherit from Team…
A: Please upvote me, I am providing you the correct answer below. Please please I need it badly.…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: The correct answer is (E) Seed Explanation: The composite class known as a concrete component class…
Q: Implement a class Clock whose get_hours and get_minutes member functions return the current time at…
A: Inupt for the code is given below which I have run I am attaching in the answer input and output…
Q: Q3: Suppose we have a class (for example name A). Write a program which consists of the following…
A: Here is the C++ Program:
Q: Suppose we have made the following assignment. alist [1, 2, [3, "Alice", 4], "Hello"]
A: Correct answer is option c. 1 <class 'int'>
Q: O 88 h Money h Money ) No Selection 1 #ifndef MONEY_H 2 #define MONEY_H 3 #include 4 using…
A: Object oriented programming contains various features like class and objects, inheritance,…
Q: Consider the Prolog gcd program in Figure 1.2. Does this program work “backward” as well as forward?…
A: Solution Dear... The Prolog definition of gcd makes use of GCD's recursive definition, which are:…
Q: 1. (Composition) Write a Pizza class so that this client code works. Please note that it is ok if…
A: # The Pizza class should have two attributes(data items): class Pizza: # The Pizza class should…
Q: Q. Run and find output • class Name: • def _init_(self, FName, mi, LName): self. FName = FName…
A: class Name: def_init__(self, FName, mi, LName) self.FName = FName self.mi = mi…
Q: Hello, I am having trouble with this homework question Q1: Implement a class called Vehicle. a)…
A: Task : Write a C++ program for given question. C++ program :- #include <iostream>using…
Q: 6. Consider the following classes and discuss/evaluate them in terms of Coupling, Cohesion…
A: Bоосh рrороses five metriсs tо meаsure the quаlity оf сlаsses:…
Q: REATE ANOTHER CLASS FOR TEAM
A: Program Approach: 1- First, created a class name as Team. 2- Inside the class name declare all the…
Q: Implement the design of the Student and Lawyer class derived from Person class so that the following…
A: The answer is
Q: b. public class Dog ( String breed; int age, String color, void barking() { } void hungry) { } void…
A: Need to convert below shown image code snippet into complete encapsulation. Encapsulation is the…
Q: Q6/write program using classes (private, public, main) to find the a varage for 3 students by…
A: Since no programming language is mentioned, I am using java. Code: import java.util.*;class Students…
Q: 1. Use the Python to declare the following classes. Hint: Document is the parent class, and Book and…
A: Please find the code for the given problem import datetime class Document: def __init__(self):…
Q: /Please Fix this probem. #include #include Class Soccer { Int g_no, no_assist, no_goal;…
A: /* all c in cout and cin was in capital, so, changed C to small c. */#include <iostream>…
Q: ar wordA[20] = "SPRING HAS"; ar wordB [20] = "SPRUNG"; ar wordC[20]; t n1, n2; a. What is the value…
A: A) in the characters array index starts from 0 so the value of wordA[4] gives the value in the 5 th…
Q: Problem 8 Create a class GreekAlphabet. Write EXACTLY 2 lines of code which generate any of the 24…
A: Note: Answering in python as no language is mentioned. Input : Lower and upper greek alphabets…
Q: Q5: Continue with House class: a) Copy the previous program to a new file. Implement prefix and…
A: In C++ we can overload operator in the same way we overload functions. In operator oerloading values…
Q: 21 What is the output of the following code? blic class Test { ublic static void main(String[] args)…
A: Algorithm: for (initialExpression; testExpression; updateExpression){ // body of the…
Q: Write a program to write for detail of n doctors by allocating the memory at run time only.
A: Program: // C++ Version 14#include <iostream>using namespace std;// Class definitionclass…
Q: Question: 3 Implement the design of the Doctor and Engineer class derived from Person class so that…
A: Question given: A program code is given, that implements classes. Write class code that produce…
Q: Consider the following class declaration: class Student { public: int * grades; Student (int n) { //…
A: b. deleting s1 also deletes s2
Q: 2) Consider the following class class Department { private: string name; const long locationNo;…
A: Program descriptionThe class definition has the declarations of the static variables, regular…
Q: 23.21 LAB: The_str_() method Write a_str_) instance method for the Number class, which returns a…
A: Solution: Given,
Q: 1. Replace the (????) with relevant code to make th eprogram function. Details about the code are…
A: hasNextLine() is used to check whether there is next line or not whereas hasNext() is used to check…
Q: Use a Bootstrap class to center the following text: Hello World!
A: Ans : Use a Bootstrap class to center the following text: <p class="text-center">Hello…
Q: uestion: 3 Implement the design of the Student_Tutor class that inherit from Student class so that…
A: Note: As programming language is not specifically mentioned in the question. So I used Java language…
Q: Exercise 5 - Monty Hall Problem Make a new class in the Lab3 project called MontyHall. Inside this…
A: Java code is implemented below for Monty hall problem
Q: Q2:[f we e c)if we have the following two classes defined class Matrix { int m- 0; public Matrix() {…
A: Given Java code: class Matrix { int m = 0; public Matrix() { m = 5; } public…
Q: Q1: Implement a class called Animal. a) A class named Animal b) Private data members: species and…
A: #include <iostream>using namespace std;//implementing Animal class//Aclass Animal{…
Q: 7 public static void start() 8 Scanner input = new Scanner(System.in); 10 11 String [Unumbers= {"2",…
A: Corrections: Import required libraries. Below libraries are required in the program to use Scanner…
Q: 1 #ifndef COIN_H 2 #define COIN_H 3 4 class Coin 5 { 6 public: Coin(double value); -Coin(); double…
A: Program In this program, data members are defined in header file Coin.h. The Demo.cpp program use…
Q: 22B. Create another class named Student that is publically inherited from Person • It has two…
A: According to the question we have to write the C++ code for following question:
Q: ample: Input Result after a train crashed, every single person died. who survived?all of the…
A: The program is written in Java. Please find the source code and output in the following steps.
Q: char xusername[10]; char xbankname[10]; int xaccountnum[4]; int xcardnum[14]; int…
A: Flow chart is a step by step process of the program which is represented using different symbols and…
Q: architecture = ScienceExam(100,120,"Physics","HigherMaths","Drawing") print(architecture)…
A: Below the code, I take the ScienceExam class to compile the code I use in python language for this…
Q: Implement a class called Vehicle. a) A class named Vehicle b) Two private data members: brand…
A: Implement a class called Vehicle. a) A class named Vehicleb) Two private data members: brand…
Q: . Identify the errors in the following codes, i.e. tell where the errors are, explain why they…
A: In option a, the self is undefined and thus has to be passed as first parameter of methods of class…
Q: Q1: Implement a class called Animal. a)A class named Animal b) Private data members: species and…
A: “Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: thon program ; Implement the design of the Doctor and Engineer class derived from Person class so…
A: We need to implement the Doctor and Engineer code as per the given description.
Q: 1. Identify the errors in the following codes, i.e. tell where the errors are, explain why they…
A: Given: Identify the errors in the following codes by pointing out where they occur, explaining why…
Q: c++ A FastCritter moves twice as fast as a regular critter. When asked to move by n steps, it…
A: /////////////////////// criter.h file given in question ///////////////////////////////#ifndef…
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Step by step
Solved in 3 steps with 3 images
- 7.21 LAB: Random values use Java. In the file RandomNumbers.java, write a class called RandomNumbers that has three integer instance variables: var1, var2, and var3. Write getter method for each variable: getVar1(), getVar2() and getVar3(). Then write the following 2 instance methods: setRandomValues( ) - accepts a low and high integer values as parameters, and sets var1, var2, and var3 to random numbers (generated using the Random class) within the range of the low and high input values (inclusive). getRandomValues( ) - prints out the 3 random numbers in the format: "Random values: var1 var2 var3" Ex: If the input is: 15 20 the output may be: Random values: 17 15 19 where 17, 15, 19 can be any random numbers within 15 and 20 (inclusive). Note: When submitted, your program will be tested against different input range to verify if the three randomly generated values are within range. import java.util.Scanner; public class LabProgram {// main method used to test your codepublic…9.19 LAB: BankAccount class (EO) Build a class called BankAccount that manages checking and savings accounts. The class has three private member fields: a customer name (String), the customer's savings account balance (double), and the customer's checking account balance (double). Implement the following Constructor and instance methods: public BankAccount(String newName, double amt1, double amt2) - set the customer name to parameter newName, set the checking account balance to parameter amt1 and set the savings account balance to parameter amt2. (amt stands for amount) public void setName(String newName) - set the customer name public String getName() - return the customer name public void setChecking(double amt) - set the checking account balance to parameter amt public double getChecking() - return the checking account balance public void setSavings(double amt) - set the savings account balance to parameter amt public double getSavings() - return the savings account balance…[2/25, 05:28] Vishal Singh Rawat: Kindly store employee details using class with python program [2/25, 05:28] Vishal Singh Rawat: There are 4 employees Details of all employee: Name: John , Designation: Manager , Salary: 80000 Name: Mike , Designation: Team Leader , Salary: 50000 Name: Derek , Designation: Programmer , Salary: 30000 Designation: Assistant , Salary: 25000 Name: Raj
- 23.6 LAB: BankAccount class (Use Python) Build a class called BankAccount that manages checking and savings accounts. The class has three attributes: a customer name, the customer's savings account balance, and the customer's checking account balance. Implement the following constructor and instance methods as listed below: Constructor with parameters (self, new_name, checking_balance, savings_balance) - set the customer name to parameter new_name, set the checking account balance to parameter checking_balance, and set the savings account balance to parameter savings_balance. deposit_checking(self, amount) - add parameter amount to the checking account balance (only if positive) deposit_savings(self, amount) - add parameter amount to the savings account balance (only if positive) withdraw_checking(self, amount) - subtract parameter amount from the checking account balance (only if positive) withdraw_savings(self, amount) - subtract parameter amount from the savings account…1. Replace the (????) with relevant code to make th eprogram function. Details about the code are given below:(Java as been used) a) This program creates a reference to a file in main() and passes the reference to countWords() countWords(), not main(), reads the file and displays Total lines Total words Average words per line */ package finalexamtakehome1; import java.io.*; /** * * @author sweetkim */ public class Finalexamtakehome1 { // public static void countWords(????) { int lineCount = 0; int wordCount = 0; while (????()) { String line = input.nextLine(); lineCount++; Scanner lineScan = new Scanner(line); while (????()) { String next = lineScan.next(); wordCount++; } } double averageWords = (double) wordCount / lineCount; System.out.println("Total lines = " + lineCount); System.out.println("Total words = " + wordCount); System.out.printf("Average words per line =…10.11 C++ The base class Pet has protected data members petName, and petAge. The derived class Cat extends the Pet class and includes a private data member for catBreed. Complete main() to: create a generic pet and print information using PrintInfo(). create a Cat pet, use PrintInfo() to print information, and add a statement to print the cat's breed using the GetBreed() function. Ex. If the input is: Dobby 2 Kreacher 3 Scottish Fold the output is: Pet Information: Name: Dobby Age: 2 Pet Information: Name: Kreacher Age: 3 Breed: Scottish Fold
- 7.21 LAB: Triangle area comparison (classes) Given class Triangle (in files Triangle.h and Triangle.cpp), complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is larger, and output that triangle's info, making use of Triangle's relevant member functions. Ex: If the input is: 3.0 4.0 4.0 5.0 where 3.0 is triangle1's base, 4.0 is triangle1's height, 4.0 is triangle2's base, and 5.0 is triangle2's height, the output is: Triangle with larger area: Base: 4.00 Height: 5.00 Area: 10.001. Identify the errors in the following codes, i.e. tell where the errors are, explain whythey become errors, and show how to fix the errors.a.class Triangle: def __init__(base, altitude): self.base = base self.altitude = altitudeb.class Triangle: def __init__(self, base, altitude) self.base = base self.altitude = altitudec.class Triangle: def __init__(self, base=1, altitude): self.base = base self.altitude = altitude//Please Fix this probem. #include <iostream.h> #include<conio.h> Class Soccer { Int g_no, no_assist, no_goal; Public : soccer () { j_no=0; No_assist=0; No_goal=0; } Void read () { Cout<<”Enter the player information (no of jersey, no of goals and no of assists):”; Cin>>j_no>>no_goal>>no_assist; } void display () { Cout<<”The information of best scorer player is :” Cout<<”Jersery no of player:”<<j_no; Cout<<”No of goals :”<<no_goal; Cout<<”No of assists :”<<no_assist; } Soccer operator >(Soccer P) { Soccer temp; If((no_assist + no_goals )>(y.no_assist + y.no_goals)) { Temp.j_no=j_no; Temp.no_assist=no_assist; Temp.no_goal=no_goal; } Else { Temp.j_no=j_no; Temp.no_assist=y.no_assist; Temp.no_goal=y.no_goal; } Return(temp); } Void main () { Soccer P[11],L; Int I; For(i=0;i<=11;i++) { P[i].read(); } L=p[0]; For(i=1;i<=11;i++) { L=L>P[i]; } L.display(); getch(); }
- 23.5 LAB: Random values (Use Python) In main.py define the RandomNumbers class, which has three integer attributes: var1, var2, and var3. Write getter method for each attribute: get_var1(), get_var2() and get_var3(). Then write the following 2 instance methods: set_random_values( ) - accepts a low and high integer values as parameters, and sets var1, var2, and var3 to random numbers within the range of the low and high input values (inclusive). get_random_values( ) - prints out the 3 random numbers in the format: "Random values: var1 var2 var3" Ex: If the input is: 15 20 the output may be: Random values: 17 15 19 where 17, 15, 19 can be any random numbers within 15 and 20 (inclusive). Note: When submitted, your program will be tested against different input range to verify if the three randomly generated values are within range.7.23 LAB: Product class use Java. Given main(), define the Product class (in file Product.java) that will manage product inventory. Product class has three private member fields: a product code (String), the product's price (double), and the number count of product in inventory (int). Implement the following Constructor and member methods: public Product(String code, double price, int count) - set the member fields using the three parameters public void setCode(String code) - set the product code (i.e. SKU234) to parameter code public String getCode() - return the product code public void setPrice(double p) - set the price to parameter p public double getPrice() - return the price public void setCount(int num) - set the number of items in inventory to parameter num public int getCount() - return the count public void addInventory(int amt) - increase inventory by parameter amt public void sellInventory(int amt) - decrease inventory by parameter amt Ex. If a new Product object is…1. Identify the errors in the following codes, i.e. tell where the errors are, explain whythey become errors, and show how to fix the errors.a.class Triangle: def __init__(base, altitude): self.base = base self.altitude = altitudeb.class Triangle: def __init__(self, base, altitude) self.base = base self.altitude = altitudec.class Triangle: def __init__(self, base=1, altitude): self.base = base self.altitude = altitude 2. Assume that the Circle class is defined as follows:import mathclass Circle: def __init__(self, radius=1): self._radius = radius def setRadius(self, radius): self._radius = radius def getRadius(self): return self._radius def area(self): return math.pi * self._radius * self._radius def circumference(self): return 2 * math.pi * self._radius 3. Determine the output produced by the following codes and explain why c = Circle()print(c.getRadius())print(c.area())c = Circle(4)print(c.getRadius())print(c.area())c = Circle(3)print(c.circumference())c =…